Set a reference to MS VBScript dll, then add this code:
Code:
Dim re as New RegExp, _
eMatch As Match, _
eMatches As MatchCollection
re.Global = False ' first match only, true is all matches
re.Pattern = "\d*" ' Any number of digits [0-9] in a row
eMatches = re.Execute("abcd19") ' Creates a collection of
' all the matches
For Each eMatch in eMatches ' Loop through all matches
Msgbox eMatch.Value
Next
Try this. This will pick up all the digits at the end of the string
Code:
Dim strVal As String, _
intNum As Integer, _
i As Integer
strVal = "abcd19"
For i = 1 To Len(strVal)
If IsNumeric(Mid(strVal, Len(strVal) - (i - 1), 1)) Then
intNum = Val(Right(strVal, i))
Else
Exit For
End If
Next i
MsgBox intNum
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.