Atlanta Custom Software Development 

 
   Search        Code/Page
 

User Login
Email

Password

 

Forgot the Password?
Services
» Web Development
» Maintenance
» Data Integration/BI
» Information Management
Programming
  Database
Automation
OS/Networking
Graphics
Links
Tools
» Regular Expr Tester
» Free Tools

GetUSStates - Get the list of US States and their abbreviations

Total Hit ( 3240)

Rate this article:     Poor     Excellent 

 Submit Your Question/Comment about this article

Rating


 


Click here to copy the following block
' return the list of US States and their abbreviations
'
' returns a bi-dimensional array organized in this way
'     res(n, 0) holds the state's name
'     res(n, 1) holds the state's abbreviation
' the array is sorted on states' names
'
' Example: load the states' names and abbreviations in a combobox
'     Dim st() As String, i As Integer
'     st() = GetUSStates()
'     For i = 0 To UBound(st)
'       Combo1.AddItem st(i, 1) & vbTab & st(i, 0)
'     Next


Function GetUSStates() As String()
  Dim temp() As String
  Dim states(0 To 49, 0 To 1) As String
  Dim i As Integer
  
  ' semi-colon delimited list of US states
  ' note that it can't be longer than 10 lines
  Const STATES_LIST = "Alabama;AL;Alaska;AK;Arizona;AZ;Arkansas;AR;California;" _
    & "CA;" & "Colorado;CO;Connecticut;CT;Delaware;DE;Florida;FL;Georgia;GA;" _
    & "" & "Hawaii;HI;Idaho;ID;Illinois;IL;Indiana;IN;Iowa;IA;" & _
    "Kansas;KS;Kentucky;KY;Louisiana;LA;Maine;ME;Maryland;MD;" & _
    "Massachusetts;MA;Michigan;MI;Minnesota;MN;Mississippi;MS;Missouri;MO;" _
    & "Montana;MT;Nebraska;NE;Nevada;NV;New Hampshire;NH;New Jersey;NJ;" & _
    "New Mexico;NM;New York;NY;North Carolina;NC;North Dakota;ND;Ohio;OH;" _
    & "Oklahoma;OK;Oregon;OR;Pennsylvania;PA;Rhode Island;RI;South " _
    & "Carolina;SC;" & _
    "South Dakota;SD;Tennessee;TN;Texas;TX;Utah;UT;Vermont;VT;" & _
    "Virginia;VA;Washington;WA;West Virginia;WV;Wisconsin;WI;Wyoming;WY"
  ' get a temporary array
  temp() = Split(STATES_LIST, ";")
  
  ' load into the result array
  For i = 0 To UBound(states)
    states(i, 0) = temp(i * 2)
    states(i, 1) = temp(i * 2 + 1)
  Next
  
  ' assign to the result
  GetUSStates = states
End Function


Submitted By : Nayan Patel  (Member Since : 5/26/2004 12:23:06 PM)

Job Description : He is the moderator of this site and currently working as an independent consultant. He works with VB.net/ASP.net, SQL Server and other MS technologies. He is MCSD.net, MCDBA and MCSE. In his free time he likes to watch funny movies and doing oil painting.
View all (893) submissions by this author  (Birth Date : 7/14/1981 )


Home   |  Comment   |  Contact Us   |  Privacy Policy   |  Terms & Conditions   |  BlogsZappySys

© 2008 BinaryWorld LLC. All rights reserved.