All pastes #275968 Raw Edit

Stuff

public text v1 · immutable
·published 2006-12-11 22:22 UTC
rendered paste body
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 = objMatch.Value
			End If
		Next
	Else
		GetStationNumber = -1
	End If
End Function

MsgBox(GetStationNumber("Station-7111"))