CutLeftNumber

Cuts the left part of string as long as it is number
Keeps getting characters one-by-one from left part of string until non-numeric character found.
Ignores space before or after numeric characters.

CodeFunctionName
What is this?

Public

Tested

Original Work
Function CutLeftNumber(StringWithNumber)
    ' Cuts the left part of string if it is number
    ' Cuts only the left part of string until non-numeric char found
    Trimmed = Trim(StringWithNumber)
    Rett = ""
    For I = 1 To Len(Trimmed)
        ASC1 = Mid(Trimmed, I, 1)
        ASC2 = Asc(ASC1)
        If ASC2 >= 48 And ASC2 <= 57 Then
            Rett = Rett & ASC1
        ElseIf ASC1 = " " Then
            ' ignore space
        Else
            ' Any other character, break and exit
            Exit For
        End If
    Next
    CutLeftNumber = Val(Rett)
End Function

StringWithNumber

Print CutLeftNumber("120px")
120

Print CutLeftNumber(" 32490 stars found today!")
32490

Views 165

Downloads 54

CodeID
DB ID