Function Val() rounding numbers

Ammarhm

Beginner User
Local time
Today, 04:47
Joined
Jul 3, 2008
Messages
80
Hi!
I am using the VBA function val(string) to convert the numerical content of a string to numbers
The problem is that it is rounding the numbers!
ex Val ("1.2") returns 1 instead of the wanted 1.2
is there any other command or solution for this to get the numbers without rounding?
Best Regards
 
i don't think so - you are probably using an integer/long to store the value

eg

somevariable = val(somestring)


if somevariable is an integer datatype, then trhe conversion will drop the decimal point. somevariable needs to be designed as a double,

note that val will stop at the first non numeric character - although i am sure you appreciate that.
 
i don't think so - you are probably using an integer/long to store the value

eg

somevariable = val(somestring)


if somevariable is an integer datatype, then trhe conversion will drop the decimal point. somevariable needs to be designed as a double,

note that val will stop at the first non numeric character - although i am sure you appreciate that.

Thank you man, that solved the problem
 

Users who are viewing this thread

Back
Top Bottom