Hi,
You don't say what program you are getting the data from.
However lets say you have the data in a string called
Address$ and Address$="Long Beach CA 1234".
There are a number of ways to extract the state address, some more difficult than others.
Because the length of the city is not known the start position of the state code is also not known. You can also not search for the preceeding space because in the example shown Long Beach has a preceeding space before the word Beach.
However if the zip code must be entered and its length is fixed then this can be used.
State$=mid$(Address$,len (address$)-(ZL+3),2)
where ZL is the zip code length and the 3 because thats the precceding space before the zip code + the two character state code.
But like I said you need to make sure the zip code is entered and the code is the correct length.
A more elaborate method is the following
First dimension an array with all the state codes
Dim States(No of States) as string
Then define each element of the array with the state code
Statec(1) = "NY"
statec(2) = "CA"
etc
then have a for and next loop to search the string for the precence of the state code eg.
State$="No State Found"
StateN$="No State Found"
For temp = 1 to No of States
if instr(Address$," "+statec(temp)+" "

<> 0 then
State$=statec(temp)
StateN$=statename$(temp) 'See text Below
Endif
Next Temp
This searches the string for <SPACE>State Code<SPACE> for each of the states you have in your array. If no state is found then State$ equals "No State Found"
This method has the advantage of being independent of the state codes position in the string and the length of the string. and providing you have no 2 letter cities in the states it should work.
Another advantage is you coud have another array with the expaned names in it for the same postion eg
Statecode(2)="NY"
Statename(2)="New York"
That way after you have found the state you could see the full name of the state in the application you need to extract the data for.
I hope this makes sense to you.
If not and you have any problems then feel free to reply.
Regards