I have a barcode string that has leading zeros that i need to remove. I cant seem to find a way to remove them. Any help would be appreciated. Thanks.
brute force
while left(s,1)="0"
s=mid(s,2)
wend
there are better ways… but this is a quick method
If you always deal with numerical based barcodes:
Dim s As String = “0004567890123”
Dim v As Double = val(s)
Dim nS As String = Format( v, “#” )
system.DebugLog(nS)
[quote=264071:@]If you always deal with numerical based barcodes:
Dim s As String = “0004567890123”
Dim v as Double = val(s)
system.DebugLog( Format( v, “#” ) )[/quote]
that assumes the string is fully numeric… that would not work if there were any non-numeric characters involved…
I realise that, which is why I put “If you always deal with numerical based barcodes” in there
dim rx as new RegEx
rx.SearchPattern = "^0+"
rx.ReplacementPattern = ""
s = rx.Replace( s )
1 Like
LOL… I knew Kem would have a RegEx solution… I can wrap my head around alot of things… but RegEx is NOT one of them