Solved

Address problem

Posted on 2004-09-08
8
227 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 500 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 85

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
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
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 85

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…

789 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