CLng, CDbl, CInt, CBool, CDate, CStr

All these functions work in a similar way they all convert a specified expression to the respective type.

Use -

VB Code:
  1. Clng([Expression]) as long
  2.  CDbl([Expression]) as Double
  3.  CInt([Expression]) as Integer
  4.  CBool([Expression]) as Boolean
  5.  CDate([Expression]) as Date
  6.  CStr([Expression]) as String

[Expression] being the thing we wish to convert, the functions explain themselves but i'll just go through what each does,

CLng - Converts a specified expression so it will fit into a long variable type
CDbl - Converts a specified expression so it will fit into a Double variable type
CInt - Converts a specified expression so it will fit into a Integer variable type
CBool - Converts a specified expression so it will fit into a Boolean variable type
CDate - Converts a specified expression so it will fit into a date variable type
CStr - Converts a specified expression so it will fit into a string variable type

Example

To use these functions is very simple, (myLong, myString etc are defined varibles as there name suggest so myString will be a string etc)

VB Code:
  1. myLong = CLng(Text1.text)
  2.  'Text1 must contain digits
  3.  myDouble = CDbl(Text1.text)
  4.  'Text1 must contain digits
  5.  myInteger = CInt(Text1.text)
  6.  'Text1 must contain digits (Whole numbers no decimals)
  7.  myBoolean = CBool(Text1.text)
  8.  'Text1.text must contain True Or False or 0 or 1
  9.  myDate = CDate(text1.text)
  10.  'Text1 must contain a valid date ie (26/10/1926)
  11.  myString = CStr(Text1.text)
  12.  'You wouldnt need to do this since text1.text is allready a string :)

Note - trying to convert impossible expressions will result in a Type Mismatch Error ie

VB Code:
  1. myBoolean = CBool("Ya Its Not Gonna Work")