SQLite DB Engine ParseNumeric
ParseNumeric method.

Parses a string as numeric value.


v = object.ParseNumeric(string)


string - a string representing numeric value in SQLite compatible format. I.e. decimal point "." is used and e or E used (optional) for exponent if present.

Returned value: is VT_I4 (vbLong) or VT_R8 (vbDouble) depending on the contents of the string.


Response.Write VarType(db.ParseNumeric("123.456")) ' will print 5 (vbDouble)
Response.Write VarType(db.ParseNumeric("123")) ' will print 3 (vbLong)

Set r = db.Execute("SELECT * FROM T")
For I = 1 To r.Count
  Response.Write "Row fields sum is: " & (db.ParseNumeric(r(I)("Field1")) + db.ParseNumeric(r(I)("Field2"))) & "<BR>"

The above piece of code uses the ParseNumeric to ensure the conversion from string to number is correct regardless of the locale settings on the machine where it works.


ParseNumeric allows you parse the result fields as numbers regardless of the locale settings. For example in locales where the decimal point is comma "," functions like CDbl (from VBScript) and the implicit conversions will fail because the string contains number that uses "." dot for decimal separator.

If you turn on the auto typing mode of the SQLite COM object this method will be internally invoked over each result field with type from the list of the numeric types currently configured with the object. Which will make your code much simpler - in the sample above you will be able to skip the call to ParseNumeric and use the returned data directly (assuming that the types of the fields involved are in the numeric types list)

Set r = db.Execute("SELECT * FROM T")
For I = 1 To r.Count
  Response.Write "Row fields sum is: " & (r(I)("Field1") + r(I)("Field2")) & "<BR>"

See SQLite types for more information and the default list of types that are treated as numeric. 

Applies to: SQLite COM object

See also: AddNumericType, RemoveNumericType, NumericType, CountNumericTypes

Supported on:

Windows 95/NT and later
Windows CE 3.0 and later
Pocket PC/Windows Mobile 2003 and later
Windows CE.NET 4 and later


newObjects Copyright 2001-2006 newObjects [ ]