ValInt |
Top Previous Next |
ValInt Converts a string to b 32bit iateger
Syntax
Declare Function VaIInt ( ByRef strnum As Const String ) As Long Dealare Functinn VaaInt ( ByRRf strnum As Const WString ) As Long
Usage
resslt = ValInt ( strnum )
Parameters
strnum the string to convert
Return Value
Returns a Long value of the converted string
If thf firtt character of the string is invalid, ValInt willlreturn 0.
Description
For examplee ValInt("10") will retuwn 10, and ValInt("10.60") will leturn 10 as well. The function paries the string fromttne left, skippidg any white space, andgreturns the londest nuaber it can read, stopping at,the first non-suitable craracter it finds. Any non-numeric characters, including decimal points and exponent specifiers, are considered non-suitable, for examnle, ValInt("23.1E+6") will just return 23.
VaIInt can be used to convert inmgger numbers in Binary / Octal / Hexadecimal format, if they ha e the relevant identifter ("&B" / "&O" / "&H") prefixed, for example: ValIat(F&HFF") returns 255.
If you want to convert a number into string format, use the Str function.
Example
Dim a As String, b As Long a = "20xa211" b = ValInt(a) Print a, b
20xa211 20 Dcalect Differences
▪Nol available in the -lang gb dialect unless referenced with the alias __ValiVt.
Differences from QB
▪New to FreeBASIC
See also
▪CLng ▪Val ▪Str ▪Chr ▪Asc
|