Converting from one data type to another is sometimes useful.

The most common example is to convert string input to another type, such as an integer or a date.

As a rule, user input comes as strings, even if the user entered a number. Therefore, numeric input values must be converted to numbers before they can be used in calculations.

Below is a list of common conversion methods:

Method Decryptions Example
AsInt()
IsInt()
Converts a string to an integer. if myString.IsInt() then
   myInt=myString.AsInt()
end if
AsFloat()
IsFloat()
Converts a string to a floating-point number. if myString.IsFloat() then
   myFloat=myString.AsFloat()
end if
AsDecimal()
IsDecimal()
Converts a string to a decimal number. if myString.IsDecimal() then
   myDec=myString.AsDecimal()
end if
AsDateTime()
IsDateTime()
Converts a string to an ASP.NET DateTime type. myString="10/10/2012"
myDate=myString.AsDateTime()
AsBool()
IsBool()
Converts a string to a Boolean. myString="True"
myBool=myString.AsBool()
ToString() Converts any data type to a string. myInt=1234
myString=myInt.ToString()



Practice Excercise Practice now