0

I have a line of text that is an address: 1234 N. Main Street Atlanta 30000 Georgia

I want the only text remaining to be Georgia. What is the VBscript to do this? I am new to VBscripting but not to coding. Thanks!

1 Answer 1

0

This is not necessarily the best way, but you could split it into an array on the space, and take the last element.

arrAddress = Split(szAddress, " ")
szState = arrAddress(UBound(arrAddress))

You could also use InStrRev to locate the position of the last space, and use Right(string, length) to pull the state out.

1
  • UBound(a) is the last index (not the size/length) of a; so please remove the -1. Jul 13, 2012 at 20:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.