找回密码
 加入
搜索
查看: 1483|回复: 7

[AU3基础] 关于循环变量赋值的问题![已解决]

  [复制链接]
发表于 2011-10-23 23:49:12 | 显示全部楼层 |阅读模式
本帖最后由 mtvtop 于 2011-12-3 00:26 编辑
        For $j=1 to 18
        If GUICtrlRead($"Checkbox"&j) = $GUI_CHECKED then
                _kj_xy($j)
        EndIf
Next
错误提示:无效格式的变量或者宏
发表于 2011-10-24 00:24:23 | 显示全部楼层
本帖最后由 tsui 于 2011-10-24 00:25 编辑

for语句格式好像有问题
 楼主| 发表于 2011-10-24 00:46:07 | 显示全部楼层
next加上也是这个问题
发表于 2011-10-24 02:47:15 | 显示全部楼层
#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
发表于 2011-10-24 05:15:13 | 显示全部楼层
本帖最后由 netegg 于 2011-10-24 05:17 编辑

eval('Checkbox' & $j)?
assign('Checkbox' & $j, 1)?
发表于 2011-10-24 08:59:09 | 显示全部楼层
$"Checkbox"&j  ???

变量写法不对!
4楼和5楼的方法应该都行得通。
发表于 2011-10-24 09:16:23 | 显示全部楼层
本帖最后由 水木子 于 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
 楼主| 发表于 2011-10-24 13:09:17 | 显示全部楼层
谢谢大家,认真学习了
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-10-1 12:14 , Processed in 0.099669 second(s), 20 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表