# val

### val(source)

Convert a string to a number. The source string is assumed to be in the correct format for the current locale.

## Arguments

Argument | Data Type | Description
source | string | Number to be converted

## Returns

The number value of the string.

## Description

Converts a string to a number. Unlike the equivalent dBase function, the val() function will accept numbers in the default format for the current locale. Thus val("1,234.56") will work correctly in the UK and US; val("1.234,56") will work correctly in European countries.

## Examples

The examples all show a number as the source for clarity - you can of course use a Field ID to get the contents of a field instead.

Example | Returns | Description
val("123") | 123 | Simplest possible format - just gives you the number
val("1,234") | 1234 | Adds spaces at the front to pad the string
val("1,234.56") | 1234.56 | Can specify decimal points

## See Also

ston(), ntos(), str(), Number Formatting