Convert text to number? ie number(text) or?

  • Thread starter Thread starter agahagan
  • Start date Start date
A

agahagan

Guest
Hello,

I have a number stored as text (for reasons I can't change) in a table. I need to perform math functions on this value, but obviously can't if its datatype is string. Is there such a function as number(text) or something?

TIA,
AG
 
Check out CInt([FieldName]) in the help. You can convert text to integer using this.

Col
:cool:
 
Assuming:

Dim S as String, L as Long
S = [some string value]
L = [some long value]

you can convert a string to its numeric equivalent by:

L = Val(S)

or convert the numeric to its string equivalent by:

S = Format(L) or S = CStr(L) or S = Str(L)

There are subtle differences between Format, CStr and Str, relating to which numeric values they will accept and how the resulting string is formatted, so check the help screens.
 
Also, you might want to check out csng and cdbl.

Fuga.
 

Users who are viewing this thread

Back
Top Bottom