Jibberish Posted July 31, 2017 Posted July 31, 2017 I am trying to get the results of a radio button selection. I have tried implementing sample scripts but to no avail. Can someone tell / show me what I am doing wrong? expandcollapse popup#include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> Local $bSelect1 Local $bSelect2 Local $bSelect3 SelectButton() ;The results of SelectButton is not being returned MsgBox(0,"","Select1 is "& $bSelect1 & ". Select2 is "& $bSelect2 & ". Select3 is "& $bSelect3 & ".") Func SelectButton() Local $hGUI = GUICreate("SGX4CP Tests", 300, 300) GUISetState() Local $bSelect1 = GUICtrlCreateRadio("Select 1", 10, 160) Local $bSelect2 = GUICtrlCreateRadio("Select 2", 10, 190) Local $bSelect3 = GUICtrlCreateRadio("Select 3", 10, 220) ; Set TestSelectForever as the default radio button GUICtrlSetState($bSelect1, $GUI_CHECKED) Local $idClose = GUICtrlCreateButton("Start", 120,250) Local $idMsg While 1 $idMsg = GUIGetMsg() Select Case $idMsg = $GUI_EVENT_CLOSE Or $idMsg = $idClose ExitLoop Case $idMsg = $bSelect1 And BitAND(GUICtrlRead($bSelect1), $GUI_CHECKED) = $GUI_CHECKED MsgBox(0,"","Select1") Case $idMsg = $bSelect2 And BitAND(GUICtrlRead($bSelect2), $GUI_CHECKED) = $GUI_CHECKED MsgBox(0,"","Select2") Case $idMsg = $bSelect3 And BitAND(GUICtrlRead($bSelect3), $GUI_CHECKED) = $GUI_CHECKED MsgBox(0,"","Select3") ; GUICtrlRead($hGUI) EndSelect WEnd MsgBox(0,"","Select1 is "& $bSelect1 & ". Select2 is "& $bSelect2 & ". Select3 is "& $bSelect3 & ".") ; Why is this returning numbers? EndFunc NYCmitch25 1
water Posted July 31, 2017 Posted July 31, 2017 The only "error" I see is the double definition of the variables $bSelectx. Use: $bSelect1 = GUICtrlCreateRadio("Select 1", 10, 160) $bSelect2 = GUICtrlCreateRadio("Select 2", 10, 190) $bSelect3 = GUICtrlCreateRadio("Select 3", 10, 220) My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
Skeletor Posted August 3, 2017 Posted August 3, 2017 (edited) Hi Jibberish, First I took your Start Button and wrapped an If Else Endif statement into it, to read the results of the Radio button. I've also cleaned your script up. Took away your function. No need to wrap it in a func. expandcollapse popup#include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $hGUI = GUICreate("SGX4CP Tests", 300, 300, 192, 124) $bSelect1 = GUICtrlCreateRadio("Select 1", 10, 160) $bSelect2 = GUICtrlCreateRadio("Select 2", 10, 190) $bSelect3 = GUICtrlCreateRadio("Select 3", 10, 220) $idClose = GUICtrlCreateButton("Start", 120, 250) GUISetState(@SW_SHOW) ; Set TestSelectForever as the default radio button GUICtrlSetState($bSelect1, $GUI_CHECKED) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $bSelect1 MsgBox(0, "", "Select1") Case $bSelect2 MsgBox(0, "", "Select2") Case $bSelect3 MsgBox(0, "", "Select3") Case $idClose $bSelect1 = GUICtrlRead($bSelect1) $bSelect2 = GUICtrlRead($bSelect2) $bSelect3 = GUICtrlRead($bSelect3) If $bSelect1 = 1 Then $Radio1 = String("checked") Else $Radio1 = String("not checked") EndIf If $bSelect2 = 1 Then $Radio2 = String("checked") Else $Radio2 = String("not checked") EndIf If $bSelect3 = 1 Then $Radio3 = String("checked") Else $Radio3 = String("not checked") EndIf MsgBox(0, "Results", "Select1 is " & $Radio1 & ". Select2 is " & $Radio2 & ". Select3 is " & $Radio3 & ".") ExitLoop EndSwitch WEnd Edited August 3, 2017 by Skeletor Jibberish and NYCmitch25 1 1 Kind RegardsSkeletor "Coffee: my defense against going postal." Microsoft Office Splash Screen | Basic Notepad Program (Beginner) | Transparent Splash Screen | Full Screen UI
Jibberish Posted August 7, 2017 Author Posted August 7, 2017 Thank you Skeletor! Now I just have to understand why it works! Always learning! Jibberish Skeletor 1
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now