Function HouseNumber(strInString As String) As Long
Dim intLen As Integer
Dim intCounter As Integer
Dim strNumber As String
Dim blnFoundNumber As Boolean
Dim fGetHouseNumberOrName As String
blnFoundNumber = False
strInString = Trim(strInString) 'Removes leading & trailing spaces
intLen = Len(strInString) 'Stores original length
intCounter = 1 'Counter & position marker
If strInString = "" Or IsNull(strInString) Or intLen = 0 Then Exit Function 'validate we didn't get passed an empty/null string
Do
If IsNumeric(Mid(strInString, intCounter, 1)) Then 'Check if that single character is a number
blnFoundNumber = True
strNumber = strNumber & Mid(strInString, intCounter, 1) 'If it is add to existing ones (if any)
intCounter = intCounter + 1 'Add to counter so we know to go to next character on the next pass/loop
Else
If intCounter = 1 Then Exit Do 'The first Character "is Not Numeric" so don't Check any more, so Exit
If blnFoundNumber = True Then Exit Do 'This Character is "is Not Numeric" so your House number is finished, so Exit
intCounter = intCounter + 1 'It "is Not Numeric", add to counter so we know to skip it
End If
Loop Until intLen = (intCounter - 1) 'Go until we processed all characters. The reason we have to do intCounter -1 is that Len starts at 0 & we told intCounter to start at 1
If IsNumeric(strNumber) Then
fGetHouseNumberOrName = strNumber
Else
fGetHouseNumberOrName = strInString
End If
End Function 'fGetHouseNumberOrName