How do I convert a string to an integer

dahljam

New Member
Licensed User
I am sure this is about the simplest question possible for b4ppc. I can't find in math or strings help, how to do this (string to number). I want to convert a string eg. "21.6" to an array integer (216).

Qbasic had a command val().

Jim Dahlquist
Delete this thread
 

ceaser

Active Member
Licensed User
Hi

NSBasic also had a "val()" command. But how about the following:

Sub......
Dim A

A=Substring("123.6",1,5)
A=format(a,"N3")
End Sub

Does your string actually have the inverted commas? If so get rid of them and format it.

Regards
Michael
 

dahljam

New Member
Licensed User
Hi Ceaser

I don't think the sub does it. I have a string, and I want an int16.
The string "21.6" then becomes the int16 216. I don't thin I can put
string types into an integer array.

The decimal point can easily be eliminated from the string but I put it
there in case a command may also handles that.

dahljam
 

dahljam

New Member
Licensed User
Ok. Now I get it

It seems that the compiler handles it.

If I assign int16 matrix(0,0)=20.6 and then place matrix(0,0) in a text box, I get "20".

Whereas if I assign int16 matrix(0,0)=20.6*10, and place matrix(0,0) in a text box, I get "206", and if I place matrix(0,0)/10 in the text box, I get "20.6".

I haven't seen that before. I would expect errors. So I just needed the nerve to try it.

Very nice.
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…