【已解决】如何读取数组里面的变量,然后再返回变量值
本帖最后由 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
MsgBox("", "", GUICtrlRead($array[$i]))
Next
Local $array = StringSplit("$Ctrlbox0,$Ctrlbox1,$Ctrlbox2,$Ctrlbox3,$Ctrlbox4,$Ctrlbox5,$Ctrlbox6,$Ctrlbox7,$Ctrlbox8,$Ctrlbox9", ",")
For $i = 1 To $array
MsgBox("", "", "$array[" & $i & "] - " & $array[$i])
Next
我想读的是控件的是控件的值不是数组本身的值
数组是控件的名字 Local $array = StringSplit("$Ctrlbox0,$Ctrlbox1,$Ctrlbox2,$Ctrlbox3,$Ctrlbox4,$Ctrlbox5,$Ctrlbox6,$Ctrlbox7,$Ctrlbox8,$Ctrlbox9", ",")
For $i = 1 To $array
MsgBox("", "", "$array[" & $i & "] - " & Eval(StringTrimLeft($array[$i],1)))
Next 我想返回的是控件的内容啊 回复 5# 3131210
這樣應該可以了....... 在數組 不要存名稱請直接存 控件ID
Local $array = StringSplit($Ctrlbox0&","&$Ctrlbox1&","&$Ctrlbox2&","&$Ctrlbox3&","&$Ctrlbox4&","&$Ctrlbox5&","&$Ctrlbox6&","&$Ctrlbox7&","&$Ctrlbox8&","&$Ctrlbox9, ",")
For $i = 1 To $array
MsgBox("", "","控件ID:"&$array[$i]&"其值是:"&GUICtrlRead($array[$i]))
Next 回复 6# kk_lee69
非常感谢,知道了,终于读出来了 回复 7# 3131210
請注意板規問題解決了請修改標題
页:
[1]