我使用vb 2010,我有变量,我想用数组填充它们。所以,在数组中是可变的。 示例:
public rbt_ckd , nozzle_c, carrier_x as integer
public state(3) as integer
dim arrayX() as integer = {rbt_ckd,nozzle_c,carrier_x}
for i as integer = 0 to 2
arrayX(i) = state(i)
next
我尝试了这种脚本格式。但它不起作用。
如何在VB.NET中执行此操作?
答案 0 :(得分:0)
更改Public
的{{1}}:
Dim
请注意,填充是按值而非参考。 (参见添加的
Sub Test() Dim rbt_ckd, nozzle_c, carrier_x As Integer Dim state(3) As Integer state(0) = 10 'sample added state(1) = 11 'sample added state(2) = 12 'sample added Dim arrayX() As Integer = {rbt_ckd, nozzle_c, carrier_x} For i As Integer = 0 To 2 arrayX(i) = state(i) Next Debug.Print(rbt_ckd) ' this will print 0, not 10 End Sub
的输出。)