0

我想在另一个人的价值之后用它的名字制作一个变量。

这是一个例子:

    While loopBool
        loopTimes = 0
        FolderBrowserDialog1.ShowDialog()
        If DialogResult.OK Then
            Dim [loopTimes] As String = FolderBrowserDialog1.SelectedPath() 
        End If
        'Some more stuff
    End While

我希望 [loopTimes] 是变量 loopTimes 的值,但我无法弄清楚。提前致谢

4

1 回答 1

1

The best way to accomplish this is to use a dictionary:

Dim myDict As New Dictionary(Of Integer, String)()

Then, you can add your strings to the dictionary:

While loopBool
    loopTimes = 0 'I'm assuming this is already declared somewhere?

    FolderBrowserDialog1.ShowDialog()
    If DialogResult.OK Then
        myDict(loopTimes) = FolderBrowserDialog1.SelectedPath() 
    End If
    'Some more stuff
End While
于 2013-05-30T19:11:37.777 回答