If you want to treat a memory location as another data type without converting it, then see casting.
See String Functions for additional functions to convert to and from strings.
Visual Basic 6.0
CBool | Boolean | CByte | Byte (0 to 255) | |||
CCur | Currency | Cdate | Date | |||
CDbl | Double (Floating point) | CDec | Decimal (weird) | |||
CInt | Integer (16 bits) | CLng | Long (32-bit Integer) | |||
CSng | Single (Floating point) | CStr | String | |||
Cvar | Variant | Format | String | |||
Int | Integer part of number | Asc | Byte (0 to 255) | |||
Fix | Integer part of number | Val | Numeric | |||
Hex | String | Str | String | |||
Oct | String |
Delphi
type Txx = (txRed, txBlue, txGreen); var xx : Txx ; i : integer; begin xx := txRed ; i := ord(xx) ; // converts a variable i := ord(txGreen); i := ord('s') ; // also works for characters
Converting real (floating point) numbers to integers (for a complete list, see "Arithmetic routines")
i := Trunc(x); // Always rounds towards zero i := Int(x) ; // Always rounds towards zero i := Round(x); // Rounds to the nearest integer i := Frac(x) ; // Returns the fractional part i := Ceil(x) ; // Rounds up i := Floor(x); // Rounds down