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

[系统综合] 【已解决】如何读取数组里面的变量,然后再返回变量值

  [复制链接]
发表于 2017-5-17 22:17:31 | 显示全部楼层 |阅读模式
本帖最后由 3131210 于 2017-5-23 15:24 编辑

如何读取数组里面的变量,然后再返回变量值
我有个gui,有控件为下面这样,我想设置数组 $array[]   然后再用GUICtrlRead读取里面的值   但是显示的是0
$Ctrlbox0 = GUICtrlCreateCheckbox("Ctrl + 0", 180, 96, 70, 17)
应该怎么改才可以返回控件的值?
$Ctrlbox1 = GUICtrlCreateCheckbox("Ctrl + 1", 180, 120, 70, 17)
GUICtrlSetState(-1, 1)
$Ctrlbox2 = GUICtrlCreateCheckbox("Ctrl + 2", 180, 144, 70, 17)
GUICtrlSetState(-1, 1)
$Ctrlbox3 = GUICtrlCreateCheckbox("Ctrl + 3", 180, 168, 70, 17)
GUICtrlSetState(-1, 1)
$Ctrlbox4 = GUICtrlCreateCheckbox("Ctrl + 4", 180, 192, 70, 17)
GUICtrlSetState(-1, 1)
$Ctrlbox5 = GUICtrlCreateCheckbox("Ctrl + 5", 180, 216, 70, 17)
$Ctrlbox6 = GUICtrlCreateCheckbox("Ctrl + 6", 180, 240, 70, 17)
$Ctrlbox7 = GUICtrlCreateCheckbox("Ctrl + 7", 180, 264, 70, 17)
$Ctrlbox8 = GUICtrlCreateCheckbox("Ctrl + 8", 180, 288, 70, 17)
$Ctrlbox9 = GUICtrlCreateCheckbox("Ctrl + 9", 180, 312, 70, 17)
    Local $array = StringSplit("$Ctrlbox0,$Ctrlbox1,$Ctrlbox2,$Ctrlbox3,$Ctrlbox4,$Ctrlbox5,$Ctrlbox6,$Ctrlbox7,$Ctrlbox8,$Ctrlbox9", ",")

    For $i = 1 To $array[0]
        MsgBox("", "", GUICtrlRead($array[$i]))
    Next
发表于 2017-5-18 13:29:03 | 显示全部楼层

Local $array = StringSplit("$Ctrlbox0,$Ctrlbox1,$Ctrlbox2,$Ctrlbox3,$Ctrlbox4,$Ctrlbox5,$Ctrlbox6,$Ctrlbox7,$Ctrlbox8,$Ctrlbox9", ",")

        
For $i = 1 To $array[0] 
        MsgBox("", "", "$array[" & $i & "] - " & $array[$i])
Next
 楼主| 发表于 2017-5-18 13:58:08 | 显示全部楼层
我想读的是控件的是控件的值  不是数组本身的值
数组是控件的名字
发表于 2017-5-18 14:18:58 | 显示全部楼层
Local $array = StringSplit("$Ctrlbox0,$Ctrlbox1,$Ctrlbox2,$Ctrlbox3,$Ctrlbox4,$Ctrlbox5,$Ctrlbox6,$Ctrlbox7,$Ctrlbox8,$Ctrlbox9", ",")

        
For $i = 1 To $array[0]
        MsgBox("", "", "$array[" & $i & "] - " & Eval(StringTrimLeft($array[$i],1)))
Next
 楼主| 发表于 2017-5-18 23:36:23 | 显示全部楼层
我想返回的是控件的内容啊
发表于 2017-5-19 01:53:19 | 显示全部楼层
回复 5# 3131210

這樣應該可以了....... 在數組 不要存名稱  請直接存 控件ID


Local $array = StringSplit($Ctrlbox0&","&$Ctrlbox1&","&$Ctrlbox2&","&$Ctrlbox3&","&$Ctrlbox4&","&$Ctrlbox5&","&$Ctrlbox6&","&$Ctrlbox7&","&$Ctrlbox8&","&$Ctrlbox9, ",")

For $i = 1 To $array[0]
         MsgBox("", "","控件ID:"&$array[$i]&"其值是:"&GUICtrlRead($array[$i]))
Next
 楼主| 发表于 2017-5-19 05:55:51 | 显示全部楼层
回复 6# kk_lee69


    非常感谢,知道了,终于读出来了
发表于 2017-5-22 02:22:59 | 显示全部楼层
回复 7# 3131210

請注意板規  問題解決了請修改標題
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-4-20 21:34 , Processed in 0.079318 second(s), 23 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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