Sign in to follow this  
Followers 0
HockeyFan

Help with Array fucntion and Radio Buttons

11 posts in this topic

#1 ·  Posted (edited)

Hello!

I've created this script to have a user select the city and state that they work in, but I'm having trouble figuring out the Array and Radio button code to display or "Read" the selected Radio button. Can someone help me with the code to show the selected radio button when the OK button is pressed?

Thanks!

#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <GUIConstants.au3>
#include <GuiButton.au3

Local $CityArray[112] = ["Akron, OH","Albany, NY","Albuquerque, NM","Alexandria, VA","Amherst, NY","Anchorage, AK","Atlanta, GA","Austin, TX","Bala Cynwyd, PA","Baltimore, MD","Baton Rouge, LA","Bentonville, AR","Bethlehem, PA","Billings, MT","Bingham Farms, MI","Birmingham, AL","Boston, MA","Bridgewater, NJ","Brookfield, WI","Cedar Rapids, IA","Charlotte, NC","Chesapeake, VA","Chicago, IL","Cincinnati, OH","Columbia, SC","Columbus, OH","Corpus Christi, TX","Dallas, TX","Decatur, IL","Denver, CO","East Syracuse, NY","Emeryville, CA","Eugene, OR","Evansville,IN","Everett, WA","Fargo, ND","Fort Lauderdale, FL","Fort Worth, TX","Fresno, CA","Glen Allen, VA","Grand Rapids, MI","Greenville, SC","Harrisburg, PA","Honolulu, HI","Houston, TX","Huntsville, AL","Hurricane, WV","Independence, OH","Indianapolis, IN","Jackson, MS","Jacksonville, FL","Knoxville, TN","Las Vegas, NV","Lexington, KY","Little Rock, AR","Los Angeles, CA","Louisville, KY","Lubbock, TX","Maitland, FL","Manchester, NH","McAllen, TX","Melville, NY","Memphis, TN","Miami, FL","Middletown, CT","Midland, TX","Montona, WI","Nashville, TN","New Orleans, LA","New York, NY","Oklahoma City, OK","Omaha, NE","Overland Park, KS","Pensacola, FL","Phoenix, AZ","Pittsburgh, PA","Portland, OR","Portland, ME","Providence, RI","Raleigh, NC","Richland, WA","Rochester, NY","Sacramento, CA","Saint Louis, MO","Salt Lake City, UT","San Antonio, TX","San Diego, CA","San Jose, CA","Santa Ana, CA","Savannah, GA","Seattle, WA","South Burlington, VT","Spokane, WA","Springfield, MO","St. Louis Park, MN","Tampa, FL","Tucson, AZ","Tulsa, OK","Urbandale, IA","Utica, NY","Washington, DC","West Palm Beach, FL","White Plains, NY","Wichita, KS","Wilmington, DE"]

$GUI = GUICreate("", 775, 626, -1, -1,BitOR($WS_EX_TOPMOST,$WS_EX_WINDOWEDGE))

$Label1 = GUICtrlCreateLabel("Please select the city where your office is located:", 25, 8, 500, 25, $SS_CENTERIMAGE)
GUICtrlSetFont(-1, 12, 800, 0, "Arial")
;GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetColor(-1, 0x000000)
$Group1 = GUICtrlCreateGroup("", 24, 32, 725, 468)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;First Row
$Radio0 = GUICtrlCreateRadio ($CityArray[0], 50, 50, 150, 17)
$Radio1 = GUICtrlCreateRadio($CityArray[1], 50, 66, 150, 17)
$Radio2 = GUICtrlCreateRadio($CityArray[2], 50, 82, 150, 17)
$Radio3 = GUICtrlCreateRadio($CityArray[3], 50, 98, 150, 17)
$Radio4 = GUICtrlCreateRadio($CityArray[4], 50, 114, 150, 17)
$Radio5 = GUICtrlCreateRadio($CityArray[5], 50, 130, 150, 17)
$Radio6 = GUICtrlCreateRadio($CityArray[6], 50, 146, 150, 17)
$Radio7 = GUICtrlCreateRadio($CityArray[7], 50, 162, 150, 17)
$Radio8 = GUICtrlCreateRadio($CityArray[8], 50, 178, 150, 17)
$Radio9 = GUICtrlCreateRadio($CityArray[9], 50, 194, 150, 17)
$Radio10 = GUICtrlCreateRadio($CityArray[10], 50, 210, 150, 17)
$Radio11 = GUICtrlCreateRadio($CityArray[11], 50, 226, 150, 17)
$Radio12 = GUICtrlCreateRadio($CityArray[12], 50, 242, 150, 17)
$Radio13 = GUICtrlCreateRadio($CityArray[13], 50, 258, 150, 17)
$Radio14 = GUICtrlCreateRadio($CityArray[14], 50, 274, 150, 17)
$Radio15 = GUICtrlCreateRadio($CityArray[15], 50, 290, 150, 17)
$Radio16 = GUICtrlCreateRadio($CityArray[16], 50, 306, 150, 17)
$Radio17 = GUICtrlCreateRadio($CityArray[17], 50, 322, 150, 17)
$Radio18 = GUICtrlCreateRadio($CityArray[18], 50, 338, 150, 17)
$Radio19 = GUICtrlCreateRadio($CityArray[19], 50, 354, 150, 17)
$Radio20 = GUICtrlCreateRadio($CityArray[20], 50, 370, 150, 17)
$Radio21 = GUICtrlCreateRadio($CityArray[21], 50, 386, 150, 17)
$Radio22 = GUICtrlCreateRadio($CityArray[22], 50, 402, 150, 17)
$Radio23 = GUICtrlCreateRadio($CityArray[23], 50, 418, 150, 17)
$Radio24 = GUICtrlCreateRadio($CityArray[24], 50, 434, 150, 17)
$Radio25 = GUICtrlCreateRadio($CityArray[25], 50, 450, 150, 17)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;Second Row
$Radio26 = GUICtrlCreateRadio($CityArray[26], 225, 50, 150, 17)
$Radio27 = GUICtrlCreateRadio($CityArray[27], 225, 66, 150, 17)
$Radio28 = GUICtrlCreateRadio($CityArray[28], 225, 82, 150, 17)
$Radio29 = GUICtrlCreateRadio($CityArray[29], 225, 98, 150, 17)
$Radio30 = GUICtrlCreateRadio($CityArray[30], 225, 114, 150, 17)
$Radio31 = GUICtrlCreateRadio($CityArray[31], 225, 130, 150, 17)
$Radio32 = GUICtrlCreateRadio($CityArray[32], 225, 146, 150, 17)
$Radio33 = GUICtrlCreateRadio($CityArray[33], 225, 162, 150, 17)
$Radio34 = GUICtrlCreateRadio($CityArray[34], 225, 178, 150, 17)
$Radio35 = GUICtrlCreateRadio($CityArray[35], 225, 194, 150, 17)
$Radio36 = GUICtrlCreateRadio($CityArray[36], 225, 210, 150, 17)
$Radio37 = GUICtrlCreateRadio($CityArray[37], 225, 226, 150, 17)
$Radio38 = GUICtrlCreateRadio($CityArray[38], 225, 242, 150, 17)
$Radio39 = GUICtrlCreateRadio($CityArray[39], 225, 258, 150, 17)
$Radio40 = GUICtrlCreateRadio($CityArray[40], 225, 274, 150, 17)
$Radio41 = GUICtrlCreateRadio($CityArray[41], 225, 290, 150, 17)
$Radio42 = GUICtrlCreateRadio($CityArray[42], 225, 306, 150, 17)
$Radio43 = GUICtrlCreateRadio($CityArray[43], 225, 322, 150, 17)
$Radio44 = GUICtrlCreateRadio($CityArray[44], 225, 338, 150, 17)
$Radio45 = GUICtrlCreateRadio($CityArray[45], 225, 354, 150, 17)
$Radio46 = GUICtrlCreateRadio($CityArray[46], 225, 370, 150, 17)
$Radio47 = GUICtrlCreateRadio($CityArray[47], 225, 386, 150, 17)
$Radio48 = GUICtrlCreateRadio($CityArray[48], 225, 402, 150, 17)
$Radio49 = GUICtrlCreateRadio($CityArray[49], 225, 418, 150, 17)
$Radio50 = GUICtrlCreateRadio($CityArray[50], 225, 434, 150, 17)
$Radio51 = GUICtrlCreateRadio($CityArray[51], 225, 450, 150, 17)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;Third Row
$Radio52 = GUICtrlCreateRadio($CityArray[52], 400, 50, 150, 17)
$Radio53 = GUICtrlCreateRadio($CityArray[53], 400, 66, 150, 17)
$Radio54 = GUICtrlCreateRadio($CityArray[54], 400, 82, 150, 17)
$Radio55 = GUICtrlCreateRadio($CityArray[55], 400, 98, 150, 17)
$Radio56 = GUICtrlCreateRadio($CityArray[56], 400, 114, 150, 17)
$Radio57 = GUICtrlCreateRadio($CityArray[57], 400, 130, 150, 17)
$Radio58 = GUICtrlCreateRadio($CityArray[58], 400, 146, 150, 17)
$Radio59 = GUICtrlCreateRadio($CityArray[59], 400, 162, 150, 17)
$Radio60 = GUICtrlCreateRadio($CityArray[60], 400, 178, 150, 17)
$Radio61 = GUICtrlCreateRadio($CityArray[61], 400, 194, 150, 17)
$Radio62 = GUICtrlCreateRadio($CityArray[62], 400, 210, 150, 17)
$Radio63 = GUICtrlCreateRadio($CityArray[63], 400, 226, 150, 17)
$Radio64 = GUICtrlCreateRadio($CityArray[64], 400, 242, 150, 17)
$Radio65 = GUICtrlCreateRadio($CityArray[65], 400, 258, 150, 17)
$Radio66 = GUICtrlCreateRadio($CityArray[66], 400, 274, 150, 17)
$Radio67 = GUICtrlCreateRadio($CityArray[67], 400, 290, 150, 17)
$Radio68 = GUICtrlCreateRadio($CityArray[68], 400, 306, 150, 17)
$Radio69 = GUICtrlCreateRadio($CityArray[69], 400, 322, 150, 17)
$Radio70 = GUICtrlCreateRadio($CityArray[70], 400, 338, 150, 17)
$Radio71 = GUICtrlCreateRadio($CityArray[71], 400, 354, 150, 17)
$Radio72 = GUICtrlCreateRadio($CityArray[72], 400, 370, 150, 17)
$Radio73 = GUICtrlCreateRadio($CityArray[73], 400, 386, 150, 17)
$Radio74 = GUICtrlCreateRadio($CityArray[74], 400, 402, 150, 17)
$Radio75 = GUICtrlCreateRadio($CityArray[75], 400, 418, 150, 17)
$Radio76 = GUICtrlCreateRadio($CityArray[76], 400, 434, 150, 17)
$Radio77 = GUICtrlCreateRadio($CityArray[77], 400, 450, 150, 17)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;Fourth Row
$Radio78 = GUICtrlCreateRadio($CityArray[78], 575, 50, 150, 17)
$Radio79 = GUICtrlCreateRadio($CityArray[79], 575, 66, 150, 17)
$Radio80 = GUICtrlCreateRadio($CityArray[80], 575, 82, 150, 17)
$Radio81 = GUICtrlCreateRadio($CityArray[81], 575, 98, 150, 17)
$Radio82 = GUICtrlCreateRadio($CityArray[82], 575, 114, 150, 17)
$Radio83 = GUICtrlCreateRadio($CityArray[83], 575, 130, 150, 17)
$Radio84 = GUICtrlCreateRadio($CityArray[84], 575, 146, 150, 17)
$Radio85 = GUICtrlCreateRadio($CityArray[85], 575, 162, 150, 17)
$Radio86 = GUICtrlCreateRadio($CityArray[86], 575, 178, 150, 17)
$Radio87 = GUICtrlCreateRadio($CityArray[87], 575, 194, 150, 17)
$Radio88 = GUICtrlCreateRadio($CityArray[88], 575, 210, 150, 17)
$Radio89 = GUICtrlCreateRadio($CityArray[89], 575, 226, 150, 17)
$Radio90 = GUICtrlCreateRadio($CityArray[90], 575, 242, 150, 17)
$Radio91 = GUICtrlCreateRadio($CityArray[91], 575, 258, 150, 17)
$Radio92 = GUICtrlCreateRadio($CityArray[92], 575, 274, 150, 17)
$Radio93 = GUICtrlCreateRadio($CityArray[93], 575, 290, 150, 17)
$Radio94 = GUICtrlCreateRadio($CityArray[94], 575, 306, 150, 17)
$Radio95 = GUICtrlCreateRadio($CityArray[95], 575, 322, 150, 17)
$Radio96 = GUICtrlCreateRadio($CityArray[96], 575, 338, 150, 17)
$Radio97 = GUICtrlCreateRadio($CityArray[97], 575, 354, 150, 17)
$Radio98 = GUICtrlCreateRadio($CityArray[98], 575, 370, 150, 17)
$Radio99 = GUICtrlCreateRadio($CityArray[99], 575, 386, 150, 17)
$Radio100 = GUICtrlCreateRadio($CityArray[100], 575, 402, 150, 17)
$Radio101 = GUICtrlCreateRadio($CityArray[101], 575, 418, 150, 17)
$Radio102 = GUICtrlCreateRadio($CityArray[102], 575, 434, 150, 17)
$Radio103 = GUICtrlCreateRadio($CityArray[103], 575, 450, 150, 17)
$Radio104 = GUICtrlCreateRadio($CityArray[104], 575, 466, 150, 17)

GUICtrlCreateGroup("", -99, -99, 1, 1)
$Button1 = GUICtrlCreateButton("OK", 325, 550, 115, 35, 0)
GUICtrlSetFont(-1, 12, 800, 0, "Arial")
$Label2 = GUICtrlCreateLabel("If your city is not listed, please enter your city and state here:", 25, 505, 400, 25, $SS_CENTERIMAGE)
GUICtrlSetFont(-1, 10, 800, 0, "Arial")
$InputCityName = GUICtrlCreateInput("", 425, 505, 300, 25, BitOR($SS_CENTER,$SS_CENTERIMAGE))
GUICtrlSetFont(-1, 10, 800, 0, "Arial")
GUICtrlSetColor(-1, 0xFF0000)
$Label2 = GUICtrlCreateLabel("Use this format: <City Name>, <State>", 445, 531, 260, 15, BitOR($SS_CENTER,$SS_CENTERIMAGE))
GUICtrlSetFont(-1, 08, 800, 0, "Arial")
GUISetState(@SW_SHOW)

While 1
 $nMsg = GUIGetMsg()
 Switch $nMsg
  Case $GUI_EVENT_CLOSE
   Exit
  Case $Button1
   For $x = 1 To UBound($CityArray) - 1
   If BitOR(GUICtrlRead($CityArray[$x]),$GUI_CHECKED) = $GUI_CHECKED Then MsgBox(0,"","Radio Button " & $CityArray[$x])
   Next
   $SelectedCity = GUICtrlRead($CityArray[$x])
EndSwitch
WEnd
Edited by HockeyFan

Share this post


Link to post
Share on other sites



Ooh, so close :) You need to use BitAND, not BitOR. And to return the text, you need to use the 'advanced' mode of GuiCtrlRead -

GuiCtrlRead($cID, 1)

Share this post


Link to post
Share on other sites

Ooh, so close :) You need to use BitAND, not BitOR. And to return the text, you need to use the 'advanced' mode of GuiCtrlRead -

GuiCtrlRead($cID, 1)

wraithdu,

I made the changes you recommended but now I get the following error message when run:

Array variable has incorrect number of subscripts or subscript dimension range exceeded.:

$SelectedCity = GUICtrlRead($CityArray[$x], 1)

$SelectedCity = GUICtrlRead(^ ERROR

What do I have wrong in the GUICtrlRead function? :)

#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <GUIConstants.au3>
#include <GuiButton.au3

Local $CityArray[112] = ["Akron, OH","Albany, NY","Albuquerque, NM","Alexandria, VA","Amherst, NY","Anchorage, AK","Atlanta, GA","Austin, TX","Bala Cynwyd, PA","Baltimore, MD","Baton Rouge, LA","Bentonville, AR","Bethlehem, PA","Billings, MT","Bingham Farms, MI","Birmingham, AL","Boston, MA","Bridgewater, NJ","Brookfield, WI","Cedar Rapids, IA","Charlotte, NC","Chesapeake, VA","Chicago, IL","Cincinnati, OH","Columbia, SC","Columbus, OH","Corpus Christi, TX","Dallas, TX","Decatur, IL","Denver, CO","East Syracuse, NY","Emeryville, CA","Eugene, OR","Evansville,IN","Everett, WA","Fargo, ND","Fort Lauderdale, FL","Fort Worth, TX","Fresno, CA","Glen Allen, VA","Grand Rapids, MI","Greenville, SC","Harrisburg, PA","Honolulu, HI","Houston, TX","Huntsville, AL","Hurricane, WV","Independence, OH","Indianapolis, IN","Jackson, MS","Jacksonville, FL","Knoxville, TN","Las Vegas, NV","Lexington, KY","Little Rock, AR","Los Angeles, CA","Louisville, KY","Lubbock, TX","Maitland, FL","Manchester, NH","McAllen, TX","Melville, NY","Memphis, TN","Miami, FL","Middletown, CT","Midland, TX","Montona, WI","Nashville, TN","New Orleans, LA","New York, NY","Oklahoma City, OK","Omaha, NE","Overland Park, KS","Pensacola, FL","Phoenix, AZ","Pittsburgh, PA","Portland, OR","Portland, ME","Providence, RI","Raleigh, NC","Richland, WA","Rochester, NY","Sacramento, CA","Saint Louis, MO","Salt Lake City, UT","San Antonio, TX","San Diego, CA","San Jose, CA","Santa Ana, CA","Savannah, GA","Seattle, WA","South Burlington, VT","Spokane, WA","Springfield, MO","St. Louis Park, MN","Tampa, FL","Tucson, AZ","Tulsa, OK","Urbandale, IA","Utica, NY","Washington, DC","West Palm Beach, FL","White Plains, NY","Wichita, KS","Wilmington, DE"]

$GUI = GUICreate("", 775, 626, -1, -1,BitOR($WS_EX_TOPMOST,$WS_EX_WINDOWEDGE))

$Label1 = GUICtrlCreateLabel("Please select the city where your office is located:", 25, 8, 500, 25, $SS_CENTERIMAGE)
GUICtrlSetFont(-1, 12, 800, 0, "Arial")
;GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetColor(-1, 0x000000)
$Group1 = GUICtrlCreateGroup("", 24, 32, 725, 468)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;First Row
$Radio0 = GUICtrlCreateRadio ($CityArray[0], 50, 50, 150, 17)
$Radio1 = GUICtrlCreateRadio($CityArray[1], 50, 66, 150, 17)
$Radio2 = GUICtrlCreateRadio($CityArray[2], 50, 82, 150, 17)
$Radio3 = GUICtrlCreateRadio($CityArray[3], 50, 98, 150, 17)
$Radio4 = GUICtrlCreateRadio($CityArray[4], 50, 114, 150, 17)
$Radio5 = GUICtrlCreateRadio($CityArray[5], 50, 130, 150, 17)
$Radio6 = GUICtrlCreateRadio($CityArray[6], 50, 146, 150, 17)
$Radio7 = GUICtrlCreateRadio($CityArray[7], 50, 162, 150, 17)
$Radio8 = GUICtrlCreateRadio($CityArray[8], 50, 178, 150, 17)
$Radio9 = GUICtrlCreateRadio($CityArray[9], 50, 194, 150, 17)
$Radio10 = GUICtrlCreateRadio($CityArray[10], 50, 210, 150, 17)
$Radio11 = GUICtrlCreateRadio($CityArray[11], 50, 226, 150, 17)
$Radio12 = GUICtrlCreateRadio($CityArray[12], 50, 242, 150, 17)
$Radio13 = GUICtrlCreateRadio($CityArray[13], 50, 258, 150, 17)
$Radio14 = GUICtrlCreateRadio($CityArray[14], 50, 274, 150, 17)
$Radio15 = GUICtrlCreateRadio($CityArray[15], 50, 290, 150, 17)
$Radio16 = GUICtrlCreateRadio($CityArray[16], 50, 306, 150, 17)
$Radio17 = GUICtrlCreateRadio($CityArray[17], 50, 322, 150, 17)
$Radio18 = GUICtrlCreateRadio($CityArray[18], 50, 338, 150, 17)
$Radio19 = GUICtrlCreateRadio($CityArray[19], 50, 354, 150, 17)
$Radio20 = GUICtrlCreateRadio($CityArray[20], 50, 370, 150, 17)
$Radio21 = GUICtrlCreateRadio($CityArray[21], 50, 386, 150, 17)
$Radio22 = GUICtrlCreateRadio($CityArray[22], 50, 402, 150, 17)
$Radio23 = GUICtrlCreateRadio($CityArray[23], 50, 418, 150, 17)
$Radio24 = GUICtrlCreateRadio($CityArray[24], 50, 434, 150, 17)
$Radio25 = GUICtrlCreateRadio($CityArray[25], 50, 450, 150, 17)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;Second Row
$Radio26 = GUICtrlCreateRadio($CityArray[26], 225, 50, 150, 17)
$Radio27 = GUICtrlCreateRadio($CityArray[27], 225, 66, 150, 17)
$Radio28 = GUICtrlCreateRadio($CityArray[28], 225, 82, 150, 17)
$Radio29 = GUICtrlCreateRadio($CityArray[29], 225, 98, 150, 17)
$Radio30 = GUICtrlCreateRadio($CityArray[30], 225, 114, 150, 17)
$Radio31 = GUICtrlCreateRadio($CityArray[31], 225, 130, 150, 17)
$Radio32 = GUICtrlCreateRadio($CityArray[32], 225, 146, 150, 17)
$Radio33 = GUICtrlCreateRadio($CityArray[33], 225, 162, 150, 17)
$Radio34 = GUICtrlCreateRadio($CityArray[34], 225, 178, 150, 17)
$Radio35 = GUICtrlCreateRadio($CityArray[35], 225, 194, 150, 17)
$Radio36 = GUICtrlCreateRadio($CityArray[36], 225, 210, 150, 17)
$Radio37 = GUICtrlCreateRadio($CityArray[37], 225, 226, 150, 17)
$Radio38 = GUICtrlCreateRadio($CityArray[38], 225, 242, 150, 17)
$Radio39 = GUICtrlCreateRadio($CityArray[39], 225, 258, 150, 17)
$Radio40 = GUICtrlCreateRadio($CityArray[40], 225, 274, 150, 17)
$Radio41 = GUICtrlCreateRadio($CityArray[41], 225, 290, 150, 17)
$Radio42 = GUICtrlCreateRadio($CityArray[42], 225, 306, 150, 17)
$Radio43 = GUICtrlCreateRadio($CityArray[43], 225, 322, 150, 17)
$Radio44 = GUICtrlCreateRadio($CityArray[44], 225, 338, 150, 17)
$Radio45 = GUICtrlCreateRadio($CityArray[45], 225, 354, 150, 17)
$Radio46 = GUICtrlCreateRadio($CityArray[46], 225, 370, 150, 17)
$Radio47 = GUICtrlCreateRadio($CityArray[47], 225, 386, 150, 17)
$Radio48 = GUICtrlCreateRadio($CityArray[48], 225, 402, 150, 17)
$Radio49 = GUICtrlCreateRadio($CityArray[49], 225, 418, 150, 17)
$Radio50 = GUICtrlCreateRadio($CityArray[50], 225, 434, 150, 17)
$Radio51 = GUICtrlCreateRadio($CityArray[51], 225, 450, 150, 17)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;Third Row
$Radio52 = GUICtrlCreateRadio($CityArray[52], 400, 50, 150, 17)
$Radio53 = GUICtrlCreateRadio($CityArray[53], 400, 66, 150, 17)
$Radio54 = GUICtrlCreateRadio($CityArray[54], 400, 82, 150, 17)
$Radio55 = GUICtrlCreateRadio($CityArray[55], 400, 98, 150, 17)
$Radio56 = GUICtrlCreateRadio($CityArray[56], 400, 114, 150, 17)
$Radio57 = GUICtrlCreateRadio($CityArray[57], 400, 130, 150, 17)
$Radio58 = GUICtrlCreateRadio($CityArray[58], 400, 146, 150, 17)
$Radio59 = GUICtrlCreateRadio($CityArray[59], 400, 162, 150, 17)
$Radio60 = GUICtrlCreateRadio($CityArray[60], 400, 178, 150, 17)
$Radio61 = GUICtrlCreateRadio($CityArray[61], 400, 194, 150, 17)
$Radio62 = GUICtrlCreateRadio($CityArray[62], 400, 210, 150, 17)
$Radio63 = GUICtrlCreateRadio($CityArray[63], 400, 226, 150, 17)
$Radio64 = GUICtrlCreateRadio($CityArray[64], 400, 242, 150, 17)
$Radio65 = GUICtrlCreateRadio($CityArray[65], 400, 258, 150, 17)
$Radio66 = GUICtrlCreateRadio($CityArray[66], 400, 274, 150, 17)
$Radio67 = GUICtrlCreateRadio($CityArray[67], 400, 290, 150, 17)
$Radio68 = GUICtrlCreateRadio($CityArray[68], 400, 306, 150, 17)
$Radio69 = GUICtrlCreateRadio($CityArray[69], 400, 322, 150, 17)
$Radio70 = GUICtrlCreateRadio($CityArray[70], 400, 338, 150, 17)
$Radio71 = GUICtrlCreateRadio($CityArray[71], 400, 354, 150, 17)
$Radio72 = GUICtrlCreateRadio($CityArray[72], 400, 370, 150, 17)
$Radio73 = GUICtrlCreateRadio($CityArray[73], 400, 386, 150, 17)
$Radio74 = GUICtrlCreateRadio($CityArray[74], 400, 402, 150, 17)
$Radio75 = GUICtrlCreateRadio($CityArray[75], 400, 418, 150, 17)
$Radio76 = GUICtrlCreateRadio($CityArray[76], 400, 434, 150, 17)
$Radio77 = GUICtrlCreateRadio($CityArray[77], 400, 450, 150, 17)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;Fourth Row
$Radio78 = GUICtrlCreateRadio($CityArray[78], 575, 50, 150, 17)
$Radio79 = GUICtrlCreateRadio($CityArray[79], 575, 66, 150, 17)
$Radio80 = GUICtrlCreateRadio($CityArray[80], 575, 82, 150, 17)
$Radio81 = GUICtrlCreateRadio($CityArray[81], 575, 98, 150, 17)
$Radio82 = GUICtrlCreateRadio($CityArray[82], 575, 114, 150, 17)
$Radio83 = GUICtrlCreateRadio($CityArray[83], 575, 130, 150, 17)
$Radio84 = GUICtrlCreateRadio($CityArray[84], 575, 146, 150, 17)
$Radio85 = GUICtrlCreateRadio($CityArray[85], 575, 162, 150, 17)
$Radio86 = GUICtrlCreateRadio($CityArray[86], 575, 178, 150, 17)
$Radio87 = GUICtrlCreateRadio($CityArray[87], 575, 194, 150, 17)
$Radio88 = GUICtrlCreateRadio($CityArray[88], 575, 210, 150, 17)
$Radio89 = GUICtrlCreateRadio($CityArray[89], 575, 226, 150, 17)
$Radio90 = GUICtrlCreateRadio($CityArray[90], 575, 242, 150, 17)
$Radio91 = GUICtrlCreateRadio($CityArray[91], 575, 258, 150, 17)
$Radio92 = GUICtrlCreateRadio($CityArray[92], 575, 274, 150, 17)
$Radio93 = GUICtrlCreateRadio($CityArray[93], 575, 290, 150, 17)
$Radio94 = GUICtrlCreateRadio($CityArray[94], 575, 306, 150, 17)
$Radio95 = GUICtrlCreateRadio($CityArray[95], 575, 322, 150, 17)
$Radio96 = GUICtrlCreateRadio($CityArray[96], 575, 338, 150, 17)
$Radio97 = GUICtrlCreateRadio($CityArray[97], 575, 354, 150, 17)
$Radio98 = GUICtrlCreateRadio($CityArray[98], 575, 370, 150, 17)
$Radio99 = GUICtrlCreateRadio($CityArray[99], 575, 386, 150, 17)
$Radio100 = GUICtrlCreateRadio($CityArray[100], 575, 402, 150, 17)
$Radio101 = GUICtrlCreateRadio($CityArray[101], 575, 418, 150, 17)
$Radio102 = GUICtrlCreateRadio($CityArray[102], 575, 434, 150, 17)
$Radio103 = GUICtrlCreateRadio($CityArray[103], 575, 450, 150, 17)
$Radio104 = GUICtrlCreateRadio($CityArray[104], 575, 466, 150, 17)

GUICtrlCreateGroup("", -99, -99, 1, 1)
$Button1 = GUICtrlCreateButton("OK", 325, 550, 115, 35, 0)
GUICtrlSetFont(-1, 12, 800, 0, "Arial")
$Label2 = GUICtrlCreateLabel("If your city is not listed, please enter your city and state here:", 25, 505, 400, 25, $SS_CENTERIMAGE)
GUICtrlSetFont(-1, 10, 800, 0, "Arial")
$InputCityName = GUICtrlCreateInput("", 425, 505, 300, 25, BitOR($SS_CENTER,$SS_CENTERIMAGE))
GUICtrlSetFont(-1, 10, 800, 0, "Arial")
GUICtrlSetColor(-1, 0xFF0000)
$Label2 = GUICtrlCreateLabel("Use this format: <City Name>, <State>", 445, 531, 260, 15, BitOR($SS_CENTER,$SS_CENTERIMAGE))
GUICtrlSetFont(-1, 08, 800, 0, "Arial")
GUISetState(@SW_SHOW)

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
  Case $GUI_EVENT_CLOSE
   Exit
  Case $Button1
   For $x = 1 To UBound($CityArray) - 1
   If BitAND(GUICtrlRead($CityArray[$x]),$GUI_CHECKED) = $GUI_CHECKED Then MsgBox(0,"","Radio Button " & $CityArray[$x])
   Next
   $SelectedCity = GUICtrlRead($CityArray[$x],1)
EndSwitch
WEnd

Share this post


Link to post
Share on other sites

Anyone!!

...any idea what I'm doing wrong here (see script above):

Array variable has incorrect number of subscripts or subscript dimension range exceeded.:
$SelectedCity = GUICtrlRead($CityArray[$x], 1)
$SelectedCity = GUICtrlRead(^ ERROR

Share this post


Link to post
Share on other sites

Here. You're trying to GuiCtrlRead() an array.......that's not gonna work.

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            For $x = 0 To UBound($CityArray) - 1
                If BitAND(GUICtrlRead(Eval("Radio" & $x)), $GUI_CHECKED) == $GUI_CHECKED Then
                    MsgBox(0, "", "Radio Button " & $CityArray[$x])
                    ExitLoop
                EndIf
            Next
            $SelectedCity = $CityArray[$x]
    EndSwitch
WEnd

Share this post


Link to post
Share on other sites

Anyone!!

...any idea what I'm doing wrong here (see script above):

Array variable has incorrect number of subscripts or subscript dimension range exceeded.:
$SelectedCity = GUICtrlRead($CityArray[$x], 1)
$SelectedCity = GUICtrlRead(^ ERROR
You were reading the array instead of the radio button. Here is your script slightly modified. I revamped the creation of the arrays and the radio buttons.

#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <GUIConstants.au3>
#include <GuiButton.au3>
#include <Array.au3>

$CityState = "Akron, OH:Albany, NY:Albuquerque, NM:Alexandria, VA:Amherst, NY:Anchorage, AK:Atlanta, GA:Austin, TX:Bala Cynwyd, PA:Baltimore, MD:Baton Rouge, LA:Bentonville, AR:Bethlehem, PA:Billings, MT:Bingham Farms, MI:Birmingham, AL:Boston, MA:Bridgewater, NJ:Brookfield, WI:Cedar Rapids, IA:Charlotte, NC:Chesapeake, VA:Chicago, IL:Cincinnati, OH:Columbia, SC:Columbus, OH:Corpus Christi, TX:Dallas, TX:Decatur, IL:Denver, CO:East Syracuse, NY:Emeryville, CA:Eugene, OR:Evansville,IN:Everett, WA:Fargo, ND:Fort Lauderdale, FL:Fort Worth, TX:Fresno, CA:Glen Allen, VA:Grand Rapids, MI:Greenville, SC:Harrisburg, PA:Honolulu, HI:Houston, TX:Huntsville, AL:Hurricane, WV:Independence, OH:Indianapolis, IN:Jackson, MS:Jacksonville, FL:Knoxville, TN:Las Vegas, NV:Lexington, KY:Little Rock, AR:Los Angeles, CA:Louisville, KY:Lubbock, TX:Maitland, FL:Manchester, NH:McAllen, TX:Melville, NY:Memphis, TN:Miami, FL:Middletown, CT:Midland, TX:Montona, WI:Nashville, TN:New Orleans, LA:New York, NY:Oklahoma City, OK:Omaha, NE:Overland Park, KS:Pensacola, FL:Phoenix, AZ:Pittsburgh, PA:Portland, OR:Portland, ME:Providence, RI:Raleigh, NC:Richland, WA:Rochester, NY:Sacramento, CA:Saint Louis, MO:Salt Lake City, UT:San Antonio, TX:San Diego, CA:San Jose, CA:Santa Ana, CA:Savannah, GA:Seattle, WA:South Burlington, VT:Spokane, WA:Springfield, MO:St. Louis Park, MN:Tampa, FL:Tucson, AZ:Tulsa, OK:Urbandale, IA:Utica, NY:Washington, DC:West Palm Beach, FL:White Plains, NY:Wichita, KS:Wilmington, DE"
$CityArray = StringSplit($CityState, ":")
Local $Radios[$CityArray[0]]

$GUI = GUICreate("", 775, 626, -1, -1, BitOR($WS_EX_TOPMOST, $WS_EX_WINDOWEDGE))

$Label1 = GUICtrlCreateLabel("Please select the city where your office is located:", 25, 8, 500, 25, $SS_CENTERIMAGE)
GUICtrlSetFont(-1, 12, 800, 0, "Arial")
;GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetColor(-1, 0x000000)
$Group1 = GUICtrlCreateGroup("", 24, 32, 725, 468)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;First Row
$aP = 50
For $aX = 1 To 26
    $Radios[$aX] = GUICtrlCreateRadio($CityArray[$aX], 50, $aP, 150, 17)
    $aP += 16
Next
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;Second Row
$bP = 50
For $bX = 27 To 52
    $Radios[$bX] = GUICtrlCreateRadio($CityArray[$bX], 225, $bP, 150, 17)
    $bP += 16
Next
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;Third Row
$cP = 50
For $cX = 53 To 78
    $Radios[$cX] = GUICtrlCreateRadio($CityArray[$cX], 400, $cP, 150, 17)
    $cP += 16
Next
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;Fourth Row
$dP = 50
For $dX = 79 To 104
    $Radios[$dX] = GUICtrlCreateRadio($CityArray[$dX], 575, $dP, 150, 17)
    $dP += 16
Next


GUICtrlCreateGroup("", -99, -99, 1, 1)
$Button1 = GUICtrlCreateButton("OK", 325, 550, 115, 35, 0)
GUICtrlSetFont(-1, 12, 800, 0, "Arial")
$Label2 = GUICtrlCreateLabel("If your city is not listed, please enter your city and state here:", 25, 505, 400, 25, $SS_CENTERIMAGE)
GUICtrlSetFont(-1, 10, 800, 0, "Arial")
$InputCityName = GUICtrlCreateInput("", 425, 505, 300, 25, BitOR($SS_CENTER, $SS_CENTERIMAGE))
GUICtrlSetFont(-1, 10, 800, 0, "Arial")
GUICtrlSetColor(-1, 0xFF0000)
$Label2 = GUICtrlCreateLabel("Use this format: <City Name>, <State>", 445, 531, 260, 15, BitOR($SS_CENTER, $SS_CENTERIMAGE))
GUICtrlSetFont(-1, 08, 800, 0, "Arial")
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            For $x = 1 To UBound($CityArray) - 2
                If BitAND(GUICtrlRead($Radios[$x]), $GUI_CHECKED) = $GUI_CHECKED Then
                    $SelectedCity = GUICtrlRead($Radios[$x], 1)
                    MsgBox(0, "", "Radio Button " & $Radios[$x])
                    MsgBox(0, "", "Selected Location " & $SelectedCity)
                EndIf
            Next
    EndSwitch
WEnd

Share this post


Link to post
Share on other sites

Here. You're trying to GuiCtrlRead() an array.......that's not gonna work.

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            For $x = 0 To UBound($CityArray) - 1
                If BitAND(GUICtrlRead(Eval("Radio" & $x)), $GUI_CHECKED) == $GUI_CHECKED Then
                    MsgBox(0, "", "Radio Button " & $CityArray[$x])
                    ExitLoop
                EndIf
            Next
            $SelectedCity = $CityArray[$x]
    EndSwitch
WEnd
wraithdu,

Once again, thank you very much. I really appreciate your help. :)

Share this post


Link to post
Share on other sites

You were reading the array instead of the radio button. Here is your script slightly modified. I revamped the creation of the arrays and the radio buttons.

#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <GUIConstants.au3>
#include <GuiButton.au3>
#include <Array.au3>

$CityState = "Akron, OH:Albany, NY:Albuquerque, NM:Alexandria, VA:Amherst, NY:Anchorage, AK:Atlanta, GA:Austin, TX:Bala Cynwyd, PA:Baltimore, MD:Baton Rouge, LA:Bentonville, AR:Bethlehem, PA:Billings, MT:Bingham Farms, MI:Birmingham, AL:Boston, MA:Bridgewater, NJ:Brookfield, WI:Cedar Rapids, IA:Charlotte, NC:Chesapeake, VA:Chicago, IL:Cincinnati, OH:Columbia, SC:Columbus, OH:Corpus Christi, TX:Dallas, TX:Decatur, IL:Denver, CO:East Syracuse, NY:Emeryville, CA:Eugene, OR:Evansville,IN:Everett, WA:Fargo, ND:Fort Lauderdale, FL:Fort Worth, TX:Fresno, CA:Glen Allen, VA:Grand Rapids, MI:Greenville, SC:Harrisburg, PA:Honolulu, HI:Houston, TX:Huntsville, AL:Hurricane, WV:Independence, OH:Indianapolis, IN:Jackson, MS:Jacksonville, FL:Knoxville, TN:Las Vegas, NV:Lexington, KY:Little Rock, AR:Los Angeles, CA:Louisville, KY:Lubbock, TX:Maitland, FL:Manchester, NH:McAllen, TX:Melville, NY:Memphis, TN:Miami, FL:Middletown, CT:Midland, TX:Montona, WI:Nashville, TN:New Orleans, LA:New York, NY:Oklahoma City, OK:Omaha, NE:Overland Park, KS:Pensacola, FL:Phoenix, AZ:Pittsburgh, PA:Portland, OR:Portland, ME:Providence, RI:Raleigh, NC:Richland, WA:Rochester, NY:Sacramento, CA:Saint Louis, MO:Salt Lake City, UT:San Antonio, TX:San Diego, CA:San Jose, CA:Santa Ana, CA:Savannah, GA:Seattle, WA:South Burlington, VT:Spokane, WA:Springfield, MO:St. Louis Park, MN:Tampa, FL:Tucson, AZ:Tulsa, OK:Urbandale, IA:Utica, NY:Washington, DC:West Palm Beach, FL:White Plains, NY:Wichita, KS:Wilmington, DE"
$CityArray = StringSplit($CityState, ":")
Local $Radios[$CityArray[0]]

$GUI = GUICreate("", 775, 626, -1, -1, BitOR($WS_EX_TOPMOST, $WS_EX_WINDOWEDGE))

$Label1 = GUICtrlCreateLabel("Please select the city where your office is located:", 25, 8, 500, 25, $SS_CENTERIMAGE)
GUICtrlSetFont(-1, 12, 800, 0, "Arial")
;GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetColor(-1, 0x000000)
$Group1 = GUICtrlCreateGroup("", 24, 32, 725, 468)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;First Row
$aP = 50
For $aX = 1 To 26
    $Radios[$aX] = GUICtrlCreateRadio($CityArray[$aX], 50, $aP, 150, 17)
    $aP += 16
Next
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;Second Row
$bP = 50
For $bX = 27 To 52
    $Radios[$bX] = GUICtrlCreateRadio($CityArray[$bX], 225, $bP, 150, 17)
    $bP += 16
Next
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;Third Row
$cP = 50
For $cX = 53 To 78
    $Radios[$cX] = GUICtrlCreateRadio($CityArray[$cX], 400, $cP, 150, 17)
    $cP += 16
Next
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;Fourth Row
$dP = 50
For $dX = 79 To 104
    $Radios[$dX] = GUICtrlCreateRadio($CityArray[$dX], 575, $dP, 150, 17)
    $dP += 16
Next


GUICtrlCreateGroup("", -99, -99, 1, 1)
$Button1 = GUICtrlCreateButton("OK", 325, 550, 115, 35, 0)
GUICtrlSetFont(-1, 12, 800, 0, "Arial")
$Label2 = GUICtrlCreateLabel("If your city is not listed, please enter your city and state here:", 25, 505, 400, 25, $SS_CENTERIMAGE)
GUICtrlSetFont(-1, 10, 800, 0, "Arial")
$InputCityName = GUICtrlCreateInput("", 425, 505, 300, 25, BitOR($SS_CENTER, $SS_CENTERIMAGE))
GUICtrlSetFont(-1, 10, 800, 0, "Arial")
GUICtrlSetColor(-1, 0xFF0000)
$Label2 = GUICtrlCreateLabel("Use this format: <City Name>, <State>", 445, 531, 260, 15, BitOR($SS_CENTER, $SS_CENTERIMAGE))
GUICtrlSetFont(-1, 08, 800, 0, "Arial")
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            For $x = 1 To UBound($CityArray) - 2
                If BitAND(GUICtrlRead($Radios[$x]), $GUI_CHECKED) = $GUI_CHECKED Then
                    $SelectedCity = GUICtrlRead($Radios[$x], 1)
                    MsgBox(0, "", "Radio Button " & $Radios[$x])
                    MsgBox(0, "", "Selected Location " & $SelectedCity)
                EndIf
            Next
    EndSwitch
WEnd
erik7426,

WOW!! :) That's so much easier...and neater. I wish I would have thought about doing it that way. Thanks for the help. :)

Share this post


Link to post
Share on other sites

Hello out there!

I have another Array/Radio button question. I have assigned another variable to the Array data ($CityState), so that when that radio button is selected not only do I get the city and state information, but a three letter city identifier (the letters that follow the "/" backslash). My question is, what do I need to do to retrieve that information from the Array without the city identifier (/xxx) being displayed in the GUI window?

I can get it to work using the following code for the "First Row":

$aP = 50
 For $aX = 1 To 26
    ;$Radios[$aX] = GUICtrlCreateRadio(StringTrimRight($CityArrayData[$aX], 4), 50, $aP, 150, 17)
     $Radios[$aX] = GUICtrlCreateRadio($CityArrayData[$aX], 50, $aP, 150, 17)
    ;GUICtrlSetColor(-1, 0xff0000)  ; Red
     $aP += 16
 Next

Any help would be much appreciated!!

#include <StaticConstants.au3>
 #include <WindowsConstants.au3>
 #include <GUIConstants.au3>
 #include <GuiButton.au3>
 #include <Array.au3>
 
 $CityState = "Akron, OH/akr:Albany, NY/alb:Albuquerque, NM/alb:Alexandria, VA/ale:Amherst, NY/amh:Anchorage, AK/anc:Atlanta, GA/atl:Austin, TX/aus:Bala Cynwyd, PA/bal:Baltimore, MD/bal:Baton Rouge, LA/bat:Bentonville, AR/ben:Bethlehem, PA/bet:Billings, MT/bil:Bingham Farms, MI/bin:Birmingham, AL/bir:Boston, MA/bos:Bridgewater, NJ/bri:Brookfield, WI/bro:Cedar Rapids, IA/ced:Charlotte, NC/cha:Chesapeake, VA/che:Chicago, IL/chi:Cincinnati, OH/cin:Columbia, SC/col:Columbus, OH/col:Corpus Christi, TX/cor:Dallas, TX/dal:Decatur, IL/dec:Denver, CO/den:East Syracuse, NY/syr:Emeryville, CA/eme:Eugene, OR/eug:Evansville,IN/eva:Everett, WA/eve:Fargo, ND/far:Fort Lauderdale, FL/lau:Fort Worth, TX/for:Fresno, CA/fre:Glen Allen, VA/gle:Grand Rapids, MI/gra:Greenville, SC/gre:Harrisburg, PA/har:Honolulu, HI/hon:Houston, TX/hou:Huntsville, AL/hun:Hurricane, WV/hur:Independence, OH/ind:Indianapolis, IN/ind:Jackson, MS/jac:Jacksonville, FL/jac:Knoxville, TN/kno:Las Vegas, NV/las:Lexington, KY/lex:Little Rock, AR/lit:Los Angeles, CA/los:Louisville, KY/lou:Lubbock, TX/lub:Maitland, FL/mai:Manchester, NH/man:McAllen, TX/mca:Melville, NY/mel:Memphis, TN/mem:Miami, FL/mia:Middletown, CT/mid:Midland, TX/mid:Montona, WI/mon:Nashville, TN/nas:New Orleans, LA/new:New York, NY/new:Oklahoma City, OK/okl:Omaha, NE/oma:Overland Park, KS/ove:Pensacola, FL/pen:Phoenix, AZ/pho:Pittsburgh, PA/pit:Portland, OR/por:Portland, ME/por:Providence, RI/pro:Raleigh, NC/ral:Richland, WA/ric:Rochester, NY/roc:Sacramento, CA/sac:Saint Louis, MO/sai:Salt Lake City, UT/sal:San Antonio, TX/san:San Diego, CA/san:San Jose, CA/jos:Santa Ana, CA/ana:Savannah, GA/sav:Seattle, WA/sea:South Burlington, VT/bur:Spokane, WA/spo:Springfield, MO/spr:St. Louis Park, MN/stl:Tampa, FL/tam:Tucson, AZ/tuc:Tulsa, OK/tul:Urbandale, IA/urb:Utica, NY/uti:Washington, DC/was:West Palm Beach, FL/wpb:White Plains, NY/whi:Wichita, KS/wic:Wilmington, DE/wil"
 $CityArrayData = StringSplit($CityState, ":")
 Local $Radios[$CityArrayData[0]]
 
 $GUI = GUICreate("", 775, 626, -1, -1, BitOR($WS_EX_TOPMOST, $WS_EX_WINDOWEDGE))
;GUISetBkColor(0x000000); Black
 $Label1 = GUICtrlCreateLabel("Please select the city where your office is located:", 25, 8, 500, 25, $SS_CENTERIMAGE)
 GUICtrlSetFont(-1, 12, 800, 0, "Arial")
;GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
 GUICtrlSetColor(-1, 0x0000ff)   ;Blue
 $Group1 = GUICtrlCreateGroup("", 24, 32, 725, 468)
 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;First Row
 $aP = 50
 For $aX = 1 To 26
    ;$Radios[$aX] = GUICtrlCreateRadio(StringTrimRight($CityArrayData[$aX], 4), 50, $aP, 150, 17)
     $Radios[$aX] = GUICtrlCreateRadio($CityArrayData[$aX], 50, $aP, 150, 17)
    ;GUICtrlSetColor(-1, 0xff0000)  ; Red
     $aP += 16
 Next
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;Second Row
 $bP = 50
 For $bX = 27 To 52
     $Radios[$bX] = GUICtrlCreateRadio(StringTrimRight($CityArrayData[$bX], 4), 225, $bP, 150, 17)
    ;$Radios[$bX] = GUICtrlCreateRadio($CityArrayData[$bX], 225, $bP, 150, 17)
    ;GUICtrlSetColor(-1, 0xff0000)  ; Red
     $bP += 16
 Next
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;Third Row
 $cP = 50
 For $cX = 53 To 78
     $Radios[$cX] = GUICtrlCreateRadio(StringTrimRight($CityArrayData[$cX], 4), 400, $cP, 150, 17)
    ;$Radios[$cX] = GUICtrlCreateRadio($CityArrayData[$cX], 400, $cP, 150, 17)
    ;GUICtrlSetColor(-1, 0xff0000)  ; Red
     $cP += 16
 Next
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;Fourth Row
 $dP = 50
 For $dX = 79 To 104
     $Radios[$dX] = GUICtrlCreateRadio(StringTrimRight($CityArrayData[$dX], 4), 575, $dP, 150, 17)
    ;$Radios[$dX] = GUICtrlCreateRadio($CityArrayData[$dX], 575, $dP, 150, 17)
    ;GUICtrlSetColor(-1, 0xff0000)  ; Red
     $dP += 16
 Next
 
 
 GUICtrlCreateGroup("", -99, -99, 1, 1)
 $Button1 = GUICtrlCreateButton("OK", 325, 550, 115, 35, 0)
 GUICtrlSetFont(-1, 12, 800, 0, "Arial")
 $Label2 = GUICtrlCreateLabel("If your city is not listed, please enter your city and state here:", 25, 505, 400, 25, $SS_CENTERIMAGE)
 GUICtrlSetFont(-1, 10, 800, 0, "Arial")
 GUICtrlSetColor(-1, 0x0000ff)   ;Blue
 $UserInputCityName = GUICtrlCreateInput("", 425, 505, 300, 25, BitOR($SS_CENTER, $SS_CENTERIMAGE))
 GUICtrlSetFont(-1, 10, 800, 0, "Arial")
 GUICtrlSetColor(-1, 0xFF0000)
 $Label2 = GUICtrlCreateLabel("Use this format: <City Name>, <State>", 445, 531, 260, 15, BitOR($SS_CENTER, $SS_CENTERIMAGE))
 GUICtrlSetFont(-1, 08, 800, 0, "Arial")
 GUICtrlSetColor(-1, 0x0000ff)   ;Blue
 GUISetState(@SW_SHOW)
 
 While 1
     $nMsg = GUIGetMsg()
     Switch $nMsg
         Case $GUI_EVENT_CLOSE
             Exit
         Case $Button1
             $UserCity = GUICtrlRead($UserInputCityName)
             If $UserCity <> "" Then MsgBox(0,"",$UserCity)
             For $x = 1 To UBound($CityArrayData) - 2
                 If BitAND(GUICtrlRead($Radios[$x]), $GUI_CHECKED) = $GUI_CHECKED Then
                     $CityIdent = StringRight(GUICtrlRead($Radios[$x], 1), 3)
                     $SelectedCity = GUICtrlRead($Radios[$x], 1)
                     MsgBox(0, "", "Radio Button " & $Radios[$x])
                     MsgBox(0, "", "Selected Location " & $SelectedCity)
                     MsgBox(0, "", "City Idnetifier = " & $CityIdent)
                     
                 EndIf
             Next
     EndSwitch
 WEnd

Share this post


Link to post
Share on other sites

*BUMP* Anyone?

Share this post


Link to post
Share on other sites

:) After taking a break and getting away, I was able to figure this out...by myself! Hurrah for me! :o

#include <StaticConstants.au3>
 #include <WindowsConstants.au3>
 #include <GUIConstants.au3>
 #include <GuiButton.au3>
 #include <Array.au3>
 
 $CityState = "Akron, OH/akr:Albany, NY/alb:Albuquerque, NM/alb:Alexandria, VA/ale:Amherst, NY/amh:Anchorage, AK/anc:Atlanta, GA/atl:Austin, TX/aus:Bala Cynwyd, PA/bal:Baltimore, MD/bal:Baton Rouge, LA/bat:Bentonville, AR/ben:Bethlehem, PA/bet:Billings, MT/bil:Bingham Farms, MI/bin:Birmingham, AL/bir:Boston, MA/bos:Bridgewater, NJ/bri:Brookfield, WI/bro:Cedar Rapids, IA/ced:Charlotte, NC/cha:Chesapeake, VA/che:Chicago, IL/chi:Cincinnati, OH/cin:Columbia, SC/col:Columbus, OH/col:Corpus Christi, TX/cor:Dallas, TX/dal:Decatur, IL/dec:Denver, CO/den:East Syracuse, NY/syr:Emeryville, CA/eme:Eugene, OR/eug:Evansville,IN/eva:Everett, WA/eve:Fargo, ND/far:Fort Lauderdale, FL/lau:Fort Worth, TX/for:Fresno, CA/fre:Glen Allen, VA/gle:Grand Rapids, MI/gra:Greenville, SC/gre:Harrisburg, PA/har:Honolulu, HI/hon:Houston, TX/hou:Huntsville, AL/hun:Hurricane, WV/hur:Independence, OH/ind:Indianapolis, IN/ind:Jackson, MS/jac:Jacksonville, FL/jac:Knoxville, TN/kno:Las Vegas, NV/las:Lexington, KY/lex:Little Rock, AR/lit:Los Angeles, CA/los:Louisville, KY/lou:Lubbock, TX/lub:Maitland, FL/mai:Manchester, NH/man:McAllen, TX/mca:Melville, NY/mel:Memphis, TN/mem:Miami, FL/mia:Middletown, CT/mid:Midland, TX/mid:Montona, WI/mon:Nashville, TN/nas:New Orleans, LA/new:New York, NY/new:Oklahoma City, OK/okl:Omaha, NE/oma:Overland Park, KS/ove:Pensacola, FL/pen:Phoenix, AZ/pho:Pittsburgh, PA/pit:Portland, OR/por:Portland, ME/por:Providence, RI/pro:Raleigh, NC/ral:Richland, WA/ric:Rochester, NY/roc:Sacramento, CA/sac:Saint Louis, MO/sai:Salt Lake City, UT/sal:San Antonio, TX/san:San Diego, CA/san:San Jose, CA/jos:Santa Ana, CA/ana:Savannah, GA/sav:Seattle, WA/sea:South Burlington, VT/bur:Spokane, WA/spo:Springfield, MO/spr:St. Louis Park, MN/stl:Tampa, FL/tam:Tucson, AZ/tuc:Tulsa, OK/tul:Urbandale, IA/urb:Utica, NY/uti:Washington, DC/was:West Palm Beach, FL/wpb:White Plains, NY/whi:Wichita, KS/wic:Wilmington, DE/wil"
 $CityArrayData = StringSplit($CityState, ":")
 Local $Radios[$CityArrayData[0]]
 Local $CityID[$CityArrayData[0]]
 
 $GUI = GUICreate("", 775, 626, -1, -1, BitOR($WS_EX_TOPMOST, $WS_EX_WINDOWEDGE))
 GUISetBkColor(0x000000); Black
 $Label1 = GUICtrlCreateLabel("Please select the city where your office is located:", 25, 8, 500, 25, $SS_CENTERIMAGE)
 GUICtrlSetFont(-1, 12, 800, 0, "Arial")
;GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
 GUICtrlSetColor(-1, 0x0000ff)   ;Blue
 $Group1 = GUICtrlCreateGroup("", 24, 32, 725, 468)
 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;First Row
 $aP = 50
 For $aX = 1 To 26
     $Radios[$aX] = GUICtrlCreateRadio(StringTrimRight($CityArrayData[$aX], 4), 50, $aP, 150, 17)
     $CityID[$aX] = $CityArrayData[$aX]
     GUICtrlSetColor(-1, 0xff0000)  ; Red
     $aP += 16
 Next
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;Second Row
 $bP = 50
 For $bX = 27 To 52
     $Radios[$bX] = GUICtrlCreateRadio(StringTrimRight($CityArrayData[$bX], 4), 225, $bP, 150, 17)
     $CityID[$bX] = $CityArrayData[$bX]
     GUICtrlSetColor(-1, 0xff0000)  ; Red
     $bP += 16
 Next
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;Third Row
 $cP = 50
 For $cX = 53 To 78
     $Radios[$cX] = GUICtrlCreateRadio(StringTrimRight($CityArrayData[$cX], 4), 400, $cP, 150, 17)
     $CityID[$cX] = $CityArrayData[$cX]
     GUICtrlSetColor(-1, 0xff0000)  ; Red
     $cP += 16
 Next
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;Fourth Row
 $dP = 50
 For $dX = 79 To 104
     $Radios[$dX] = GUICtrlCreateRadio(StringTrimRight($CityArrayData[$dX], 4), 575, $dP, 150, 17)
     $CityID[$dX] = $CityArrayData[$dX]
     GUICtrlSetColor(-1, 0xff0000)  ; Red
     $dP += 16
 Next
 
 
 GUICtrlCreateGroup("", -99, -99, 1, 1)
 $Button1 = GUICtrlCreateButton("OK", 325, 550, 115, 35, 0)
 GUICtrlSetFont(-1, 12, 800, 0, "Arial")
 $Label2 = GUICtrlCreateLabel("If your city is not listed, please enter your city and state here:", 25, 505, 400, 25, $SS_CENTERIMAGE)
 GUICtrlSetFont(-1, 10, 800, 0, "Arial")
 GUICtrlSetColor(-1, 0x0000ff)   ;Blue
 $UserInputCityName = GUICtrlCreateInput("", 425, 505, 300, 25, BitOR($SS_CENTER, $SS_CENTERIMAGE))
 GUICtrlSetFont(-1, 10, 800, 0, "Arial")
 GUICtrlSetColor(-1, 0xFF0000)
 $Label2 = GUICtrlCreateLabel("Use this format: <City Name>, <State>", 445, 531, 260, 15, BitOR($SS_CENTER, $SS_CENTERIMAGE))
 GUICtrlSetFont(-1, 08, 800, 0, "Arial")
 GUICtrlSetColor(-1, 0x0000ff)   ;Blue
 GUISetState(@SW_SHOW)
 
 AdlibEnable("UncheckRadio")
 
 While 1
     $nMsg = GUIGetMsg()
     Switch $nMsg
         Case $GUI_EVENT_CLOSE
             Exit
         Case $Button1
             $UserCity = GUICtrlRead($UserInputCityName)
             If $UserCity <> "" Then MsgBox(0,"",$UserCity)
             For $x = 1 To UBound($CityArrayData) - 2
                 If BitAND(GUICtrlRead($Radios[$x]), $GUI_CHECKED) = $GUI_CHECKED Then
                     $SelectedCity = GUICtrlRead($Radios[$x], 1)
                    ;$SelectedCity = StringTrimRight(GUICtrlRead($Radios[$x], 1), 4)
                     MsgBox(0, "", "Radio Button: " & $Radios[$x])
                     MsgBox(0, "", "Selected Location: " & $SelectedCity)
                     MsgBox(0, "", "City Identifer: " & StringRight($CityID[$x], 3))
                 EndIf
             Next   
     EndSwitch
 WEnd
 
 Func UncheckRadio()
     $UserCity = GUICtrlRead($UserInputCityName)
     If $UserCity <> "" Then
         For $x = 1 To UBound($CityArrayData) - 2
             If BitAND(GUICtrlRead($Radios[$x]), $GUI_CHECKED) = $GUI_CHECKED Then
                 GUICtrlSetState ($Radios[$x], $GUI_UNCHECKED)
             EndIf
         Next
     EndIf
 EndFunc

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0