[Webinar] Streamline your web hosting managementRegister Today

x
?
Solved

Address problem

Posted on 2004-09-08
8
Medium Priority
?
233 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
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
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 77

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

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

Question has a verified solution.

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

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
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…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses
Course of the Month10 days, 20 hours left to enroll

612 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