CVar (function)

Syntax CVar (expression)
Description Converts expression to a Variant .
Comments This function is used to convert an expression into a variant. Use of this function is not necessary (except for code documentation purposes) because assignment to variant variables automatically performs the necessary conversion:
  Sub Main() 
    Dim v As Variant
    v = 4 & "th"      'Assigns "4th" to v.
    MsgBox "You came in: " & v
    v = CVar(4 & "th")    'Assigns "4th" to v.
    MsgBox "You came in: " & v
  End Sub
Example This example converts an expression into a Variant.
Sub Main()
  Dim s As String
  Dim a As Variant
  s = CStr("The quick brown fox ")
  msg1 = CVar(s & "jumped over the lazy dog.")
  MsgBox msg1
End Sub
See Also CCur (function); CBool (function); CDate, CVDate (functions); CDbl (function); CInt (function); CLng (function); CSng (function); CStr (function); CVErr (function); Variant (data type).