VB.NET ASPNET Type Conversion Function Examples

VB.NET ASPNET Type Conversion Function Examples

Purpose: – Illustrates for .


VB.NET ASPNET Type Conversion Function Examples

Type Type Conversion Functions Input Expression Result
CBool(expression) Char, Numeric, or String Boolean
Data
Type
CByte(expression) 0 to 255 unsigned (gets rounded) Byte
Data
Type
CChar(expression) Char or String (if string, only first character is used) Char
Data
Type
CDate(expression) Date and/or time in any valid format. Date
Data
Type
CDbl(expression) -1.79769313486231570E+308 through -4.94065645841246544E-324 for negative values;4.94065645841246544E-324 through 1.79769313486231570E+308 for positive values. Double
Data
Type
CDec(expression) +/-79,228,162,514,264,337,593,543,950,335 for zero-scaled numbers, that is, numbers with no decimal places. For numbers with 28 decimal places, the range is +/-7.9228162514264337593543950335. The smallest possible non-zero number is 0.0000000000000000000000000001 (+/-1E-28). Decimal
Data
Type
CInt(expression) -2,147,483,648 through 2,147,483,647; fractional parts are rounded . Integer
Data
Type
CLng(expression) -9,223,372,036,854,775,808 through 9,223,372,036,854,775,807; fractional parts are rounded. Long
Data
Type
CObj(expression) Any valid data type. Object
Data
Type
CSByte(expression) -128 through 127; fractional parts are rounded. SByte
Data
Type
CShort(expression) -32,768 through 32,767; fractional parts are rounded Short
Data
Type
CSng(expression) -3.402823E+38 through -1.401298E-45 for negative values; 1.401298E-45 through 3.402823E+38 for positive values Single
Data
Type
CStr(expression) 1. If boolean, returns string “True” or “False” 2. If date, returns A string containing a date value (date and time) in the short date format of your system 3. If number, returns a string representing the number String
Data
Type
CUInt(expression) 0 to 4,294,967,295 – will throw exception if negative number is passed in. Rounds fractions to whole numbers UInteger
Data
Type
CULng(expression) 0 to 18,446,744,073,709,551,615 (unsigned) – will throw Exception if negative number is passed in. Rounds fractions to whole numbers ULong
Data
Type
CUShort(expression) 0 to 65,535 (unsigned) – will throw Exception if negative number is passed in. Rounds fractions to whole numbers SByte
UShort
Type