【发布时间】:2016-08-04 16:40:09
【问题描述】:
我在网上搜索了如何自动动态声明变量名,但没有找到任何结果。我正在简化的代码方法如下:
dim choice1 as string
dim choice2 as string
dim choice3 as string
...
我希望我可以按如下方式进行处理
dim count as integer
while count is 1 to 10
count +=1
end while
dim (choice+count) as string
' it suppose to create variable choice with the addition to the name from 1 to 10 like choice1, choice2, choice3 and so on.
你能帮帮我吗?
ps:我也尝试在数组中创建声明的变量,如下所示:
dim count as integer
Dim var As Array = {Dim choice1 as string, dim choice2 as string}
while count is 1 to 10
var.add(dim choice+count as string)
end while
【问题讨论】:
标签: arrays vb.net variables dynamic naming