Try this function, there's no need for loops, or brute force!
Private Function FindNumber(ByVal Msg As String, ByVal
Search As Long) As Long
Dim Found As Long
Found = InStr(1, Msg, CStr(Search))
If (Found <> 0) Then
FindNumber = CLng(Mid(Msg, Found, Len(CStr(Search))))
Else
FindNumber = &HFFFF
End If
End Function
Just pass a string to the function and a number to search for..
Example:
Dim Ret As Long
Ret = FindNumber("Trying to figure out how to do this in
less than 123 steps.", 123)
FindNumber will return the number you passed it, if it was found, if the number was not found it will return -1 or &HFFFF. In this case it will return 123.
Best Regards,
Nathan Martini
Advanced Computer Solutions