增量变量定义
我想自动定义递增变量名称。
所以不是这个:
$Var1 = 'This is variable one :P'
$Var2 = 'This is variable two :P'
我想要这个(伪代码):
For $i = 1 to UBound($People)-1
**$var[$i]** = GUICtrlCreateCheckbox($var[$i], 24, $y, 200, 17)
$y = $y + 25
Next
有谁知道怎么做?
代码应该创建与数组中定义的数量一样多的复选框,并且每个复选框都应该有自己的变量。
I want to automatically define incrementing variable names.
So instead of this:
$Var1 = 'This is variable one :P'
$Var2 = 'This is variable two :P'
I'd like this (pseudo code):
For $i = 1 to UBound($People)-1
**$var[$i]** = GUICtrlCreateCheckbox($var[$i], 24, $y, 200, 17)
$y = $y + 25
Next
Does anyone know how?
The code should make as many checkboxes as defined in an array and every checkbox should have its own variable.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您正在寻找
Assign()
:然后您可以使用以下方式访问这些变量:
显然,也可以使用
var2
和var3
。您应该做的是将这些值存储在数组中。You're looking for
Assign()
:Then you can access these variables with:
Obviously,
var2
andvar3
can be used too. What you should have done was storing those values in an array.根据文档 - 简介 - 数组:
动态复选框创建示例,将多个 checkbox-control 标识符分配给单个数组(未经测试,无错误检查):
GUICtrlCreateCheckboxMulti()
演示$aID[$iAmount]
)For...To 中的数组元素赋值。 ..Step...Next
-loop ($aID[$i1] = ...
)。Main()
演示了对单个元素的选择(使用GUICtrlSetData()
)。$g_iBoxAmount
等)。As per Documentation - Intro - Arrays:
Dynamic checkbox creation example, assigning multiple checkbox-control identifiers to a single array (untested, no error-checking):
GUICtrlCreateCheckboxMulti()
demonstrates$aID[$iAmount]
)For...To...Step...Next
-loop ($aID[$i1] = ...
).Main()
demonstrates selection of an individual element (changing its text usingGUICtrlSetData()
).$g_iBoxAmount
etc.).