faqts : Computers : Programming : Languages : Asp : ASP/VBScript : Functions

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

73 of 107 people (68%) answered Yes
Recently 7 of 10 people (70%) answered Yes

Entry

What are VBScript conversion functions?

Jun 12th, 2000 08:09
Jerry Yoakum,


Conversion functions enable you to change the subtype of a variable. 
Although VBScript uses the variant type for all variables, in many 
cases an argument of a certain type is required. An example would be 
passing a variable to a dll that expects to receive an integer.
CByte Function
  ' Converts an expression into a byte value.
  result = CByte(varTemp)
  ' If varTemp is not within the byte range, an error occurs.
CDbl Function
  ' Converts an expression into a Double value.
  result = CDbl(varTemp)
CInt Function
  ' Converts an expression into an Integer value.
  result = CInt(varTemp)
  ' If varTemp is not within an integer range, a runtime error occurs.
  ' result is rounded to the nearest whole number.
CLng Function
  ' Converts an expression into a Long value.
  result = CLng(varTemp)
  ' If varTemp is not within a Long range, a runtime error occurs.
  ' result is rounded to the nearest whole number.
CSng Function
  ' Converts an expression into a Single value.
  result = CSng(varTemp)
  ' If varTemp is not within a Single range, a runtime error occurs.
CStr Function
  ' Converts an expression into a String value.
  result = CStr(varTemp)
  ' If varTemp is Null, a runtime error occurs.
  ' If varTemp is Empty, result is a zero-length string("").
  ' If varTemp is boolean, result is "True" or "False".
  ' If varTemp is Date, result is a date in short-date format.
  ' If varTemp is Error, result is the word "Error" and the error #.
  ' If varTemp is any numeric, result is the number in string format.



© 1999-2004 Synop Pty Ltd