Val

String management function.

The Val function converts a string to a number.

Syntax

Number=Val(<string$>)

Parameters

<string$>, string to be converted to a number.

Remarks

The Val function stops reading the string at the first character which cannot be considered as a numeric. The Val function removes leading and trailing spaces.

See also

Str$

Examples

 

number = Val("123") ' Returns the integer 123

number = Val("-123") ' Returns the integer -123

number = Val("12X3") ' Returns the integer 12

number = Val(var$)

 
Dim array$(10)

ReadExcel("c:\quotation.xls","A10:A10",array$())

number=Val(array$(0)) 'ReadExcel returns a string in array$(0) which is the content of A10 cell, Val function converts to a number