Function GetStationNumber(strMachineName)
Dim regEx, objMatch, objMatches, strReturn
Set regEx = New RegExp
regEx.Pattern = "^Station-([0-9]*)$"
regEx.IgnoreCase = True
regEx.Global = True
If regEx.Test(strMachineName) then
regEx.Pattern = "[0-9]*$"
Set objMatches = regEx.Execute(strMachineName)
For Each objMatch in objMatches
If IsNumeric(objMatch.Value) Then
GetStationNumber = CInt(objMatch.Value)
End If
Next
Else
GetStationNumber = -1
End If
End Function
MsgBox(GetStationNumber("Station-7111"))