你的代码有两个问题
1、你没有弄清VB的数组下标是从0 开始还是从1 开始 所示提示下标越界
2、变量使用冲突,你定义了一 i但在不同的过程或函数中进行不恰当的使用
我对代码进行了调整
1、修改数组定义
Dim a(11) As Integer, b(11) As Integer
2、修改了command2_click 新定义了一个变量
Private Sub Command2_Click()
Dim j As Integer
For j = 1 To 10
Text2 = Text2 & nx(a(j)) & " "
Next
End Sub
If a(i) Mod 10 = 0 Then
i = i - 1
End If
Text1 = Text1 & a(i) & " "
改为
If a(i) Mod 10 = 0 Then
i = i - 1
else
Text1 = Text1 & a(i) & " "
End If
Private Sub Command1_Click()
Text1 = ""
Randomize
For i = 1 To 10
Do
a(i) = Int(900 * Rnd) + 100
Loop While a(i) Mod 10 = 0
Text1 = Text1 & a(i) & " "
Next i
End Sub