我有一个小的 vb6 程序:
Private Sub Form_Load()
Dim varTemp As Variant
Dim string1 As String
Dim x As Integer
x = 0
dialog.Filter = "toate fisierele(*.*) | *.*"
dialog.Flags = cdlOFNAllowMultiselect Or cdlOFNLongNames Or cdlOFNExplorer
'open the window to select files
dialog.ShowOpen
varTemp = Split(dialog.FileName, vbNullChar)
Do While (varTemp(x) <> "")
string1 = varTemp(x)
x = x + 1
Loop
Unload Form1
End
End Sub
我希望 Do While 循环直到它到达 varTemp 的末尾。但是,当我从对话框中选择两个文件并用 x = 3 命中“Do While”时,我得到“运行时错误'9':下标超出范围”。“Do While”循环必须在什么条件下循环直到 varTemp 结束?谢谢你。