Page 1 of 1

Decimal number in string to float conversion

Posted: Sat Nov 08, 2008 5:47 pm
by RadioT
Hello,

There are a number of nice float-to-string conversions, but how about the other way?

Let's say I'm converting a string of 123.456 to a float.

When it's always the same number of characters in front of the decimal, I can use the mid function, such as when pulling the 2 leading characters from the GPS time string to get the hour:

GPS_hour = StrToDec(Mid(GMT_time,0,2))

This works because even when there is one significant digit, since it's padded with a leading 0. So using place works in this case.

But when the leading numbers vary, I can build a loop to find the decimal, then assign each number to a float by dividing by the place (4/10, then 5/100, etc).

Is there a function that can do that already a part of SF? Or a more efficient way to do this?

Thanks,

de Tom