Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

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.

Latest threads

New Articles From Microcontroller Tips

Back
Top