Extracting Data out of a string
On Thu, 31 Jul 2008 19:11:00 -0700, ranswrt
wrote:
I tried your code but I'm not familiar with how to use 'split'. What I am
trying to do is get the following array:
address(1) = city
address(2) = state
address(3) = zip
Here's one way that assumes your address strings are in the manner you
presented it in your first post:
<city<comma<space<state abbrev<space<zip code
==================
Option Explicit
Sub foo()
Const sAdr As String = "Las Vegas, NV 89103"
Dim aAdr(1 To 3) As String
Dim aTemp1, aTemp2
Dim i As Long
aTemp1 = Split(Trim(sAdr), ",")
aTemp2 = Split(Trim(aTemp1(1)), " ")
aAdr(1) = aTemp1(0)
aAdr(2) = aTemp2(0)
aAdr(3) = aTemp2(1)
For i = 1 To 3
Debug.Print aAdr(i)
Next i
End Sub
===================
--ron
|