Forum Discussion

Tony2021's avatar
Tony2021
Steel Contributor
Feb 01, 2022
Solved

Strip Leading Zero's

Hello Experts,   How could I strip the leading zeros from invoice numbers so that I can simply compare on the non zeros?  My query is below and I have highlighted in red the area that I am looking ...
  • arnel_gp's avatar
    arnel_gp
    Feb 02, 2022
    you can also use RegExp to extract the number:

    Public Function fncAlphaNumber(ByVal varInput As Variant) As Variant
    varInput = varInput & ""
    fncAlphaNumber = varInput
    If Len(varInput) < 1 Then
    Exit Function
    End If
    With CreateObject("vbscript.regexp")
    .ignorecase = True
    .Global = True
    .pattern = "[^a-z0-9]"
    varInput = .Replace(varInput, "")
    While Left$(varInput, 1) = "0"
    varInput = Mid$(varInput, 2)
    Wend
    End With
    fncAlphaNumber = varInput
    End Function


    NumInvoice: fncAlphaNumber([Invoice #])