Horizon
Member in Training
Posts: 32
|
Post by Horizon on Jul 18, 2022 14:30:52 GMT
Hello,
A quick question what is the best method for translating a string variable (which also happens to be a number) to a numerical variable? Lets look as some simple code...
dim x$(20)
x$(10) = "12"
print x$(10)
Above we've set x$(10) to the string value of "12" but, lets say we want to use this x$(10) string value as a numerical value say ' y ' for a calculation later. How would I convert a string to number? Especially if the x$(10) array value can change to other numbers.
I'm probably overlooking a very simple method of achieving this, but any help would be welcome.
|
|
|
Post by honkytonk on Jul 18, 2022 14:46:29 GMT
a=val(a$) x=val(x$(10)) help is meant to be read
|
|
Horizon
Member in Training
Posts: 32
|
Post by Horizon on Jul 18, 2022 14:56:33 GMT
Hello honkytonk,
I think I was tripping over Syntax. I appreciate the nudge in the right direction.
dim x$(20) x$(10) = "12" print x$(10); " String" y = val(x$(10)) print y; " Number"
|
|
|
Post by honkytonk on Jul 18, 2022 16:35:45 GMT
Hello honkytonk, I think I was tripping over Syntax. I appreciate the nudge in the right direction. dim x$(20) x$(10) = "12" print x$(10); " String" y = val(x$(10)) print y; " Number"
12 it's number "12" it's a string a$=12 ---> error a$="12" ---> well
|
|