A A A
C  C  Off 

Iron Speed Code Customizations, casting data types.

Iron Speed builds in validation for certain controls such as DateTime checks for columns in your database with that particular data type.

But, when writing your own custom code, there are methods for performing these checks manually.

 

For instance, lets say there is a text box on your page (Start Date / End Date) and you want to check that there are no conflicting values being entered into these boxes.

Whilst overriding the validate method in the record control class, you can do something like this:

Date endDate = This.EndDate.Text;  - - This will throw a cast type exception as you cannot convert a string to a date implicitey.

Instead:

Date endDate = (Date)This.EndDate.Text; -- Will now work as an explicit cast has been made.

 

In VB.Net, the following will make an explicit conversion to a Date:

 

Dim endDate as Date = CType(Me.EndDate.Text,Date)

 

OR

 

Dim endDate as Date = CDate(Me.EndDate.Text)

 

There are many functions available for casting datatypes in VB.Net, such as CInt, CDate, CDateTime etc, and by using MSDN reference, you can hopefully find what you're looking for!

 

Ricci

  • Facebook
  • Twitter
  • Digg It!
Leave a comment
Close

Enter your details and click subscribe to sign up to our newsletter

 *
   
 
 

* Required Field

Subscribe