Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Address problem

Posted on 2004-09-08
8
Medium Priority
?
232 Views
Last Modified: 2008-02-01
I need to split up the address data.
so
12345  mystreet  
or
123 mystreet
 
they are in one field in the database  and not broken up i need to grab the number  so I'm thinking if there is some way to go to the first space of 123 mystreet. not sure how to code this to pull just the street number.
Thanks for any help
0
Comment
Question by:cdb424ttm
8 Comments
 
LVL 18

Expert Comment

by:JR2003
ID: 12007004
Val("12345  mystreet ")
will give the number 12345

JR
0
 
LVL 6

Accepted Solution

by:
bkthompson2112 earned 2000 total points
ID: 12007037
Hi cdb424ttm,

Try this:

Dim AddrParts() as string
AddrParts = Split("12345 mystreet", " ")

AddrParts(0) will contain "12345"
AddrParts(1) will contain "mystreet"

bkt
0
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 12007073
Split may not be such a good idea since if you have "12345 E Highland Drive" you will end up with "E", "Highland" and "Drive" all in seperate elements of the array.

Private Sub Command1_Click()
    Dim address As String
    Dim firstSpace As Integer
    Dim number As String
    Dim street As String
   
    address = "12345  mystreet"
    firstSpace = InStr(address, " ")
    number = Trim(Left(address, firstSpace))
    street = Trim(Mid(address, firstSpace))
End Sub
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 6

Expert Comment

by:bkthompson2112
ID: 12007316
>Split may not be such a good idea

That's true.  It will depend on the data and how it's used.

Another example:

"12345 1/2 E Highland Drive"
number = 123456
street = 1/2 E Highland Drive

The point is, neither solution is perfect.  It will depend on the data format and how the program intends to use it.
0
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 12007325

Perhaps you should look for a comma first, I used to work at "Computer House, Boston Manor Road", If missing, go for the first space.

v = Split(Address, ",")
If UBound(v) = 0 Then
    v = Split(Address, " ")
End If
building = v(0)
street = v(1)
0
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 12007344
Good point bkthompson2112.

Idle_Mind
0
 
LVL 19

Expert Comment

by:Shauli
ID: 12007509
cdb424ttm ,

I did not participate in this paq, however, I think you have selected the wrong answer.
Lets see:
JR's solution will fail if the address is "12345 72nd Street" because it will result in 1234572
bkthompson2112's (accepted answer) will fail because the result would be AddrParts(0) will contain "12345" AND AddrParts(0) will contain "72nd", so what about the rest of the address?

Idle_Mind's solution is the right solution, even if in rare cases of "12345 1/2 E Highland Drive" it does not give a solution.

You realize that the solution you have chosen will result, in this case, like this:
AddrParts(0) will contain "12345"
AddrParts(1) will contain "1/2"

Just to let you know :)

And my appology for interupting,

S
0
 
LVL 6

Expert Comment

by:bkthompson2112
ID: 12007581
Shauli,  you're exactly right.  As I pointed out, none of the proposed solutions is perfect.

I've always found address parsing to be problematic.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Suggested Courses

926 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question