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.
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
' 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
120
Print CutLeftNumber(" 32490 stars found today!")
32490
Views 232
Downloads 83
CodeID
DB ID
ANmarAmdeen
614
Revisions
v1.0
Sunday
December
31
2023