Private Sub CommandButton3_Click()
Dim Subj0, Subj1, Subj2 As String
Dim j As Integer
i = 0
Subj0 = Array("第一题", "A1", "B1", "C1", "D1")
Subj1 = Array("第二题", "A2", "B2", "C2", "D2")
Subj2 = Array("第三题", "A3", "B3", "C3", "D3")
CommandButton2.Caption = "开 始"For j = 0 To 4
Subject(0, j) = Subj0(j)
Subject(1, j) = Subj1(j)
Subject(2, j) = Subj2(j)
Next jEnd Sub
说明:Subject数组已定义,此程序运行于PPT中
这一段代码中出现了一个编译错误,“缺少数组”,错误停止在Subj2(j)这个位置
Dim Subj0, Subj1, Subj2 As String
Dim j As Integer
i = 0
Subj0 = Array("第一题", "A1", "B1", "C1", "D1")
Subj1 = Array("第二题", "A2", "B2", "C2", "D2")
Subj2 = Array("第三题", "A3", "B3", "C3", "D3")
CommandButton2.Caption = "开 始"For j = 0 To 4
Subject(0, j) = Subj0(j)
Subject(1, j) = Subj1(j)
Subject(2, j) = Subj2(j)
Next jEnd Sub
说明:Subject数组已定义,此程序运行于PPT中
这一段代码中出现了一个编译错误,“缺少数组”,错误停止在Subj2(j)这个位置
Array的返回值必须是Variant,而你像这样定义Dim Subj0, Subj1, Subj2 As String ,则恰好在VB中前两个变量类型为Variant,只有最后一个为string类型,所有出错了。