I want to parse an address from a text field.
for example -
textbox data = 123 test street, mountain view, CA 91302
-
-
Dim address = Address.text
-
-
parse(address)
to
Address1
Address2
City
State
Zip
I found someones sample code, but it doesn't work all that well.
here it is non the less -
-
Public Function parseAddress(ByVal input As String) As Collection
-
input = input.Replace(",", "")
-
input = input.Replace(" ", " ")
-
Dim splitString() As String = Split(input)
-
Dim streetMarker() As String = New String() {"street", "st", "st.", "avenue", "ave", "ave.", "blvd", "blvd.", "highway", "hwy", "hwy.", "box", "road", "rd", "rd.", "lane", "ln", "ln.", "circle", "circ", "circ.", "court", "ct", "ct."}
-
Dim address1 As String
-
Dim address2 As String = ""
-
Dim city As String
-
Dim state As String
-
Dim zip As String
-
Dim streetMarkerIndex As Integer
-
-
zip = splitString(splitString.Length - 1).ToString()
-
state = splitString(splitString.Length - 2).ToString()
-
streetMarkerIndex = getLastIndexOf(splitString, streetMarker) + 1
-
Dim sb As New StringBuilder
-
-
For counter As Integer = streetMarkerIndex To splitString.Length - 3
-
sb.Append(splitString(counter) + " ")
-
Next counter
-
city = RTrim(sb.ToString())
-
Dim addressIndex As Integer = 0
-
-
For counter As Integer = 0 To streetMarkerIndex
-
If IsNumeric(splitString(counter)) _
-
Or splitString(counter).ToString.ToLower = "po" _
-
Or splitString(counter).ToString().ToLower().Replace(".", "") = "po" Then
-
addressIndex = counter
-
Exit For
-
End If
-
Next counter
-
-
sb = New StringBuilder
-
For counter As Integer = addressIndex To streetMarkerIndex - 1
-
sb.Append(splitString(counter) + " ")
-
Next counter
-
-
address1 = RTrim(sb.ToString())
-
-
sb = New StringBuilder
-
-
If addressIndex = 0 Then
-
If splitString(splitString.Length - 2).ToString() <> splitString(streetMarkerIndex + 1) Then
-
For counter As Integer = streetMarkerIndex To splitString.Length - 2
-
sb.Append(splitString(counter) + " ")
-
Next counter
-
End If
-
Else
-
For counter As Integer = 0 To addressIndex - 1
-
sb.Append(splitString(counter) + " ")
-
Next counter
-
End If
-
address2 = RTrim(sb.ToString())
-
-
Dim output As New Collection
-
output.Add(address1, "Address1")
-
output.Add(address2, "Address2")
-
output.Add(city, "City")
-
output.Add(state, "State")
-
output.Add(zip, "Zip")
-
Return output
-
End Function
-
-
Private Function getLastIndexOf(ByVal sArray As String(), ByVal checkArray As String()) As Integer
-
Dim sourceIndex As Integer = 0
-
Dim outputIndex As Integer = 0
-
For Each item As String In checkArray
-
For Each source As String In sArray
-
If source.ToLower = item.ToLower Then
-
outputIndex = sourceIndex
-
If item.ToLower = "box" Then
-
outputIndex = outputIndex + 1
-
End If
-
End If
-
sourceIndex = sourceIndex + 1
-
Next
-
sourceIndex = 0
-
Next
-
Return outputIndex
-
End Function
-
-
-
any help would be greatly appreciated
1 2250 Sign in to post your reply or Sign up for a free account.
Similar topics |
by: steve deno |
last post by:
In 6i, if there was an LOV on an item and the user entered the field,
a box with 3 dots popped up. It seems this does not happen in 9i.
Does anyone know why? And how to make that happen?
...
|
by: Silvio |
last post by:
Here's my update statement:
UPDATE Item1
SET reviewloop = 1, currentreviewstate=5
WHERE itemid in
(SELECT itemid FROM Item2)
The thing is: the table Item2 DOES NOT HAVE a field called...
|
by: stapak |
last post by:
I have a common (I guess) problem.
I need to store my address book in format that would be independent on
any e-mail clients - preferably in XML - to work sometimes on raw data.
I tried to find...
|
by: Simon Egginton |
last post by:
Does anyone know how to make a CHAT ROOM for a webpage using java or jave
script please. I am just look at you lot because i think you are the
experts!
THANK YOU!
ewhost_simon"HI"@yahoo.co.uk...
|
by: Neil Rowe |
last post by:
Hi all
I am writing an App at the moment and I need to be able to download & Upload
xml files from an ftp server. Does anyone know how this can be done without
using a third party component.
...
| |
by: Pucca |
last post by:
I'm getting an error when I tried to use this BerConverter class in my C#
code. Even though the Interent doc says that it runs on Win2000 sp4, I just
thgouth I'll double check. Does anyone know...
|
by: =?Utf-8?B?RWxpemFiZXRo?= |
last post by:
I got a message that generic host process was connecting to the Internet.
When I did Netstat, I saw four established connections from my computer to
another port on my computer. What is going on? I...
|
by: Anonymous |
last post by:
On MS site: http://msdn2.microsoft.com/en-us/library/esew7y1w(VS.80).aspx
is the following garbled rambling:
"You can avoid exporting classes by defining a DLL that defines a class
with...
|
by: Clifford Robins |
last post by:
Not wanting to reinvent the wheel, I found an image rotator on Code Project. Since it was based on tons of javacript, I thought it would be okay, since it was made into a web control, so all you had...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
| |