O Omar Member Licensed User Longtime User Jul 2, 2011 #1 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.
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.
K kickaha Well-Known Member Licensed User Longtime User Jul 2, 2011 #2 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 B4X: numberstring = NumberFormat (8911, 11, 0) In that example numberstring will be "00000008911" Upvote 0
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 B4X: numberstring = NumberFormat (8911, 11, 0) In that example numberstring will be "00000008911"
P pappicio Active Member Licensed User Longtime User Jul 2, 2011 #3 yes! this is the solution! better if: B4X: 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: Jul 2, 2011 Upvote 0
yes! this is the solution! better if: B4X: 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(",","")
O Omar Member Licensed User Longtime User Jul 2, 2011 #4 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
K kickaha Well-Known Member Licensed User Longtime User Jul 2, 2011 #5 Omar said: 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 Click to expand... 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
Omar said: 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 Click to expand... I thank you for posting the problem as solved :sign0188: Too many times people ask questions, others provide answers and there is no feedback!
O Omar Member Licensed User Longtime User Jul 2, 2011 #6 kickaha said: I thank you for posting the problem as solved :sign0188: Too many times people ask questions, others provide answers and there is no feedback! Click to expand... 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
kickaha said: I thank you for posting the problem as solved :sign0188: Too many times people ask questions, others provide answers and there is no feedback! Click to expand... kickaha, That's the least I could do, its good folk like yourselves that are helping to make this a great community. :sign0098: