Numeric Strings to Integer

Omar

Member
Licensed User
Longtime User
Hello,

I'm working with some numeric strings that I need to convert to Integers (Long) but I found that some of my strings contain preceding zeros and when this is converted the zero is removed.

eg. 00000008911 becomes 8911
01234567890 becomes 1234567890

Is there any way to retain the zero(s) ?

Or any suggestion would be greatly appreciated.


Thanks.
 
I am really at a loss as to why you want the preceding zeros, but an Int will not retain them.

If it is so that when you (re)convert to a string for displaying you want the length to remain at (in the example case) 11 digits, use
Code: Copy
 numberstring = NumberFormat (8911, 11, 0)

In that example numberstring will be "00000008911"
 
Upvote 0
yes! this is the solution!
better if:
Code: Copy
dim a as string
dim b as double
a="00000008911"
b=a
dim  numberstring as string
numberstring = NumberFormat (b, a.length, 0)
c=c.replace(",","")
 
Last edited:
Upvote 0
Thank you kickaha and pappicio.

I appreciate your assistance, yes I need the zero's for when I convert back the numeric to string.

The NumberFormat is perfect. Thanks again for your help :)
 
Upvote 0
Thank you kickaha and pappicio.

I appreciate your assistance, yes I need the zero's for when I convert back the numeric to string.

The NumberFormat is perfect. Thanks again for your help :)

I thank you for posting the problem as solved :sign0188: Too many times people ask questions, others provide answers and there is no feedback!
 
Upvote 0
I thank you for posting the problem as solved :sign0188: Too many times people ask questions, others provide answers and there is no feedback!


kickaha,

That's the least I could do, its good folk like yourselves that are helping to make this a great community. :sign0098:
 
Upvote 0
Back
Top