Need Help with address fields

asid

Registered User.
Local time
Tomorrow, 09:28
Joined
Jan 25, 2006
Messages
22
I am trying to find a way to best strip the numeric part of an address in a string. i.e extract the address number from the street name.
Example is
21 Echo Valley Road (strip of the 21)
2 - 506 Devonport Road (strip of 2- 506)

How can I do this?
 
Code:
Public Sub AddressSplit()
Dim strTest As String
Dim intX As Integer
Dim strNumber As String
Dim strAddress As String

intX = 1
strTest = "2 - 506 Devonport Road"

Do Until Not IsNumeric(Mid(strTest, intX, 1)) And Mid(strTest, intX, 1) <> " " And Mid(strTest, intX, 1) <> "-"
    intX = intX + 1
Loop

strNumber = Left(strTest, intX - 1)
strAddress = Right(strTest, Len(strTest) - intX + 1)

Debug.Print strNumber
Debug.Print strAddress
End Sub

This code loops through your test string, and tests each character in it until the character it finds is not numeric, is not a space, and is not a hyphen. Once you know that character's position within the string, you can split it apart using the left and right functions.
 
this worked great than you..
 

Users who are viewing this thread

Back
Top Bottom