devxlogo

GetUSStates – Get the list of US States and their abbreviations

GetUSStates – Get the list of US States and their abbreviations

' 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)'          NextFunction 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 = statesEnd Function

See also  5 Benefits of Using Time Tracking Software
devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist