我有几个变量称为:_2sVal、_3sVal、_4sVal 等我想通过循环更改它们的每个值。喜欢:
For i = 1 To 10
'set the value
Next
我试过把它们放在字典里,比如:
Dim varDict As New Dictionary(Of String, Integer)
varDict.Add("2sVal", _2sVal)
varDict.Add("3sVal", _3sVal)
varDict.Add("4sVal", _4sVal)
我可以使用检索值
MsgBox(varDict(i.ToString & "sVal"))
但是当我尝试改变它时
varDict(i.ToString & "sVal") = 5
它什么也没做。也没有错误或异常,只是值保持不变