How do I convert a string to a number?

Status
Not open for further replies.

SwingeyP

Member
Hello again.

I want to convert a string to a number. (The string will only ever be a number)

I have this ..

Code:
Dim result As Byte
Dim char(10) As Byte
Dim i As Byte

Hseropen 9600

result = 0
For i = 1 To 10
char = LookUp("1234567890"), i

result = #char-30 'take chars hex value and subtract 30 from it.

Hserout result

Next i

End

This doesn't compile but I think you can see what I am trying to do.

What's the correct way of doing it?

Regards - Paul
 
like this perhaps:
Code:
For i = 0 To 10
char = LookUp("1234567890"), i

result = char - 48  'take chars hex value and subtract 48 (30 hex) from it.

Hserout #result

Next i
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…