Previous Topic: UCase - Convert Lowercase Letter to UppercaseNext Topic: ValEx - Convert Decimal, Hexadecimal, or Octal String to Integer


Val - Convert String to Integer

Valid on NetWare, Symbian OS, UNIX, Windows and Windows CE

The Val function converts the input string to an integer.

This string manipulation function has the format:

Val(str as String) as Integer
str

Identifies the string that is to be converted.

This function ignores any leading tabs or spaces and recognizes an optional sign followed by a string of digits.

The function returns the converted value of the input string. If the string cannot be converted to a number, the function returns 0.

Example: Val function

Dim i As Integer
i = Val("2735")
Print("Val(""2735"")"+Str(i))
i=ValEx("2735")
Print("ValEx(2735")
Print("ValEx(""2735"")="+str(i))
i=ValEx("01414")
Print("ValEx(""01414"")="+str(i))
i=ValEx("0x1414")
Print("ValEx(""0x1414"")="+str(i))