Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / Convert string$ to numeric variable

Author
Message
Jwhite
14
Years of Service
User Offline
Joined: 26th Nov 2009
Location:
Posted: 30th Nov 2009 21:03
I dont know why I cant see this anyplace but

I have a string$ that contains 1.1254 and I need to put
that value into the variable temp

I have tried tghe val() command but this only returns
an integer and this value is a real

Can someone help me with this please?


Thanks

<Jeff>
TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 30th Nov 2009 23:52 Edited at: 30th Nov 2009 23:55
Quote: "I have tried tghe val() command but this only returns an integer and this value is a real"


Not true.

It's the variable type which you are placing the value into that denotes the result. So, if A$ = "12.345" then...

B=VAL(A$)

results in B = 12, whereas:

B#=VAL(A$)

results in B# = 12.345

As a DBC programmer, I'm not up to speed with DBP pro, so you maybe don't need the # variable postfix - you are probably better defining a float variable instead.

If you aren't sure about floats and integers, they are covered in the series of tutorials for beginners at the top of the DB Classic board (they all still apply to DBP though).

TDK

Jwhite
14
Years of Service
User Offline
Joined: 26th Nov 2009
Location:
Posted: 1st Dec 2009 01:33
Your right, I figured out that I needed a # sign
added to the end of my variable for it to read
the real number value.

I'm used to programming in another system and I
guess I got brain locked on this one.

Plus I'm used to programming in another system, but

After reading thru the examples I was able to see
an example of this.

Thanks...

<Jeff>

Login to post a reply

Server time is: 2024-09-28 12:28:29
Your offset time is: 2024-09-28 12:28:29