关于循环变量赋值的问题![已解决]
本帖最后由 mtvtop 于 2011-12-3 00:26 编辑For $j=1 to 18
If GUICtrlRead($"Checkbox"&j) = $GUI_CHECKED then
_kj_xy($j)
EndIf
Next
错误提示:无效格式的变量或者宏 本帖最后由 tsui 于 2011-10-24 00:25 编辑
for语句格式好像有问题 next加上也是这个问题 #include <GUIConstants.au3>
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
Dim $Checkbox
$Form1 = GUICreate("", 261, 251, 340, 162)
$Checkbox1 = GUICtrlCreateCheckbox("1", 50, 50, 25, 17)
$Checkbox2 = GUICtrlCreateCheckbox("2", 120, 50, 25, 17)
$Checkbox3 = GUICtrlCreateCheckbox("3", 190, 50, 25, 17)
$Checkbox4 = GUICtrlCreateCheckbox("4", 50, 100, 25, 17)
$Checkbox5 = GUICtrlCreateCheckbox("5", 120, 100, 25, 17)
$Checkbox6 = GUICtrlCreateCheckbox("6", 190, 100, 25, 17)
$Checkbox7 = GUICtrlCreateCheckbox("7", 50, 150, 25, 17)
$Checkbox8 = GUICtrlCreateCheckbox("8", 120, 150, 25, 17)
$Checkbox9 = GUICtrlCreateCheckbox("9", 190, 150, 25, 17)
$Group1 = GUICtrlCreateGroup("10", 24, 24, 209, 169)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Button = GUICtrlCreateButton("ok", 90, 210, 75, 25, $WS_GROUP)
GUISetState(@SW_SHOW)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button
For $i=3 To 11
If GUICtrlRead($Checkbox&$i) = $GUI_CHECKED Then MsgBox(0,0,$i-2)
Next
EndSwitch
WEnd
http://www.autoitx.com/thread-8372-1-1.html 本帖最后由 netegg 于 2011-10-24 05:17 编辑
eval('Checkbox' & $j)?
assign('Checkbox' & $j, 1)? $"Checkbox"&j???
变量写法不对!
4楼和5楼的方法应该都行得通。 本帖最后由 水木子 于 2011-10-24 09:18 编辑
回复 3# mtvtop
Global $iRowNum = 5
Global $iSpacingX = 50, $iSpacingY = 50
GUICreate('', 300, 300)
For $i = 0 To 19
Assign('Checkbox' & $i, GUICtrlCreateCheckbox($i + 1, $iSpacingX * Mod($i, $iRowNum) + 25, $iSpacingY * Floor($i / $iRowNum) + 25, 50, 50))
Next
$Button = GUICtrlCreateButton("ok", 150, 250, 75, 25)
GUISetState()
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case -3
Exit
Case $Button
For $i = 0 To 19
If GUICtrlRead(Eval('Checkbox' & $i)) = 1 Then
MsgBox(0, '被勾选项目:' & $i + 1, '控件ID = ' & Eval('Checkbox' & $i))
EndIf
Next
EndSwitch
WEnd 谢谢大家,认真学习了
页:
[1]