回复 8# 水木子
帮解释一下,代码的两个地方:
;这样也可以3和6是怎么来的. 这里的 $I-3怎么来的.
如果是N个CHECKBOX 就是 3 TO N+2 个.#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Local $avArray[4] = ['150', '300', '500','1000']
Local $nNumber
GUICreate("Form1", 300, 200)
$Checkbox1 = GUICtrlCreateCheckbox($avArray[0] & 'MB', 80, 30, 100, 17)
$Checkbox2 = GUICtrlCreateCheckbox($avArray[1] & 'MB', 80, 80, 100, 17)
$Checkbox3 = GUICtrlCreateCheckbox($avArray[2] & 'MB', 80, 130, 100, 17)
$Checkbox4 = GUICtrlCreateCheckbox($avArray[3] & 'MB', 80, 160, 100, 17)
$Label1 = GUICtrlCreateLabel('0 MB', 200, 160, 100, 33)
GUISetState()
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case - 3
Exit
Case $Checkbox1 To $Checkbox4
;~ For $i = $Checkbox1 To $Checkbox4
For $i = 3 To 6 ;这样也可以3和6是怎么来的. 这里的 $I-3怎么来的.
If BitAND(GUICtrlRead($i), $GUI_CHECKED) Then $nNumber += $avArray[$i - 3]
Next
GUICtrlSetData($Label1, $nNumber & ' MB')
$nNumber = 0
EndSwitch
WEnd
|