|
-
Apr 11th, 2013, 11:09 PM
#1
Thread Starter
Hyperactive Member
[RESOLVED] Barcode Issue?
Hi everyone. I have a barcode scan thing. Anyway, my question is how can we remove or add the zero's in a barcode. In my case I have barcode read two different way as:
1- 1234
2- 001234
---> all I need is the "01234"
Can anyone help me how to omit the zero or add it if when barcode read that way?... please any advice would be appreciated.
-
Apr 11th, 2013, 11:59 PM
#2
Re: Barcode Issue?
Convert the data to a number then use the format() function to output the number in the format you wish, or convert to a number then back to a string and check the length of the new string if less than 5 add the required number of 0s to the left, or check the length of the string from the scan if greater than five drop the first digit(s) to get the required length
This is assuming that you want a 5 character result which is left padded with 0s. If that is not what you are looking for then explain in more detail
-
Apr 12th, 2013, 12:03 AM
#3
Thread Starter
Hyperactive Member
Re: Barcode Issue?
convert to a number then back to a string and check the length of the new string if less than 5 add the required number of 0s to the left.
Yes correct that's what i'm looking for. i use replace but it's omit all zero.
-
Apr 12th, 2013, 01:13 AM
#4
Re: Barcode Issue?
As DM says
Let's say that the value is 1234 or 001234
1.-
Store the value in a string variable, let's say MyStr
Convert to numeric
Dim X As Integer
X = CInt(MyStr)
Then convert to desired output using Format
MyStr = Format(X, "00000")
Or
2.-
Store the value in a string variable, let's say MyStr
Then if length equal to 4 then add one 0
If Len(MyStr) = 4 Then MyStr = "0" & MyStr
If the length is equal to 5 then cut first 0
If Len(MyStr) = 5 Then MyStr = Mid(MyStr,2)
JG
... If your problem is fixed don't forget to mark your threads as resolved using the Thread Tools menu ...
-
Apr 12th, 2013, 08:01 AM
#5
Re: [RESOLVED] Barcode Issue?
Another option that could be done with just one line would be to add 0s at the begining then take the right 5 characters
Code:
MyStr=Right$("00000" & BarcodeValue,5)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|