本帖最后由 水木子 于 2010-12-7 20:40 编辑
代码仅仅能满足眼前的需求是远远不够的,要尽可能的考虑远一些。
如:有成千上万个复选框,那该怎么办?难道要写上万行的代码吗?
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Local $avArray[3] = ['150', '300', '500']
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)
$Label1 = GUICtrlCreateLabel('0 MB', 200, 160, 100, 33)
GUISetState()
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case - 3
Exit
Case $Checkbox1 To $Checkbox3
For $i = $Checkbox1 To $Checkbox3
If BitAND(GUICtrlRead($i), $GUI_CHECKED) Then $nNumber += $avArray[$i - 3]
Next
GUICtrlSetData($Label1, $nNumber & ' MB')
$nNumber = 0
EndSwitch
WEnd
|