how to convert text to value?
Blitz3D Forums/Blitz3D Beginners Area/how to convert text to value?
| ||
I'm currently experimenting with string manipulation in blitz. I was wondering, let's say that I have a string with a number in front of it (eg: 3say, 4must). I can parse out the number using left$(), but how do I change the string to a value? Thanks! |
| ||
A$ = "3say" B% = Int(A$) |
| ||
heh! I thought int was only for numbers! but anyone, thanks so much, gfk! |
| ||
You don't actually need the Int() - B% = A$ will work just the same. However, using Int() will keep your code more readable. |
| ||
:) Thanks for clarifying things for me. cheers |
| ||
Perhaps you could clarify this issue: If you run this code, the result is 35. what should I to do get it to be 8? a$="003" b$="005" a=Int(a$) b=Int(b$) c=a+b Print c WaitKey() End |
| ||
Use different variables to convert from string to int. A and B have already been defined as strings when you declared them with a$="003" and b$="005". Change the code to c=Int(a$) and d=Int(b$) and e=c+d and it works fine. |
| ||
Aaah! I knew it would be an easy fix! :) The simplest things can be soooo hard to find! Thanks! |