Page 1 of 1

CLng, CInt, CByte, CWord ... conversions would be nice...

Posted: Thu Apr 22, 2004 1:39 am
by Shannara
I currently have a string that consists of one number "1". I would like to convert it to a long, or even a byte. How can I do this? I couldnt find any conversions in the PB manual. Except for the String (STR), but that was it. This is needed to read numbers from a combo box by NOT using the index, but by reading the text of an element.

I think the above would be quite usefull.

Posted: Thu Apr 22, 2004 9:28 am
by LarsG
number.l = Val(string$) doesn't work?

or am I missing the point here?

Posted: Thu Apr 22, 2004 3:42 pm
by Shannara
Didn't see that one coming.. hopefully it'll work with bytes. As I know PB has a problem assigning a long (that is less then 128) to a byte.

Posted: Thu Apr 22, 2004 4:00 pm
by einander
Hi Shannara:
Is this any help?

Code: Select all

s$="1"
A.L=PeekB(@s$)-48
Debug "Long :"+Str(A)
B.b=PeekB(@s$)-48 
Debug "Byte :" +Str(B)

Posted: Thu Apr 22, 2004 5:48 pm
by Fred
Shannara wrote:Didn't see that one coming.. hopefully it'll work with bytes. As I know PB has a problem assigning a long (that is less then 128) to a byte.
if the long is in the byte range, it works perfectly... We did you find this assumption ?

Posted: Thu Apr 22, 2004 6:12 pm
by Shannara
Einander:

Thanks, I'll do a test, if that works, I'll create small lib for the bugger.


Fred:

hrm, I think your probably right, I was passing a 100 byte value into a proc that accepted only longs, and then took that 100 long value and passed it to a byte variable... maybe somewhere in there...