MyEarth Posted April 29, 2013 Posted April 29, 2013 (edited) Hi i have this script:#include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Global $aArray[8] = ["0x01", "0x02", "0x04", "0x08", "0x10", "0x20", "0x40", "0x80"] Global $NumberExample = 4 Global $Checkbox_[$NumberExample + 1] Global $Label_[$NumberExample + 1] $hGUI = GUICreate("Form1", 347, 270, 192, 124) $Button = GUICtrlCreateButton("Check", 256, 232, 75, 25) For $i = 0 To $NumberExample - 1 $Checkbox_[$i] = GUICtrlCreateCheckbox("", 8, 8 + (25 * $i), 15, 15) $Label_[$i] = GUICtrlCreateLabel("Value " & $i, 25, 9 + (25 * $i), 50, 20) Next GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button Local $Value = "", $FinalHex = 0 For $i = 0 To $NumberExample - 1 If GUICtrlRead($Checkbox_[$i]) = $GUI_CHECKED Then $Value &= $aArray[StringRight(GUICtrlRead($Label_[$i]), 1)] & "|" EndIf Next $aValue = StringSplit($Value, "|") If $aValue[0] = 2 Then ; One elemen selected Then Global $FinalHex = $aValue[1] EndIf MsgBox(0,0,$FinalHex) EndSwitch WEndIf i select one checkbox i have the correct value, but the problem is i don't know how to sum two or more value of two or more checkbox, exmaple:I select the first checkbox = Value 0 = 0x01 ( in the script i have do it, don't know the method is correctI select all checkbox = Value 0 ( 0x01 = 1 ) + Value 1 (0x02 = 2 ) + Value 2 (0x04 = 4 ) + Value 3 (0x08 = 8 )1+2+4+8 = 15 --> Converted = 0x0f ( i need the 0x0f )How to do that? Thanks Edited April 29, 2013 by MyEarth
Moderators Melba23 Posted April 29, 2013 Moderators Posted April 29, 2013 MyEarth, I suggest you do this: ; Declare the array like this: Global $aArray[8] = [0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80] ; And then change the $Button Case to read: Case $Button Local $Value = "", $FinalHex = 0 For $i = 0 To $NumberExample - 1 If GUICtrlRead($Checkbox_[$i]) = $GUI_CHECKED Then $FinalHex += $aArray[$i] EndIf Next MsgBox(0, 0, "0x" & Hex($FinalHex, 2)) That gives me the correct result. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
MyEarth Posted April 29, 2013 Author Posted April 29, 2013 Was so "simple"? Thanks Melba, yes it's correct
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