【加试题】随机数排序程序。程序功能如下:窗体加载时生成[10,100]范围内的随机整数10个存储在数组a中,并在列表框List1中显示原始数据,单击“排序”按钮,这10个数据按降序排序后显示在列表框List2中。程序运行效果如图所示。实现上述功能的VB代码如下,但加框处代码有错,请改正。Dim a(1 To 10) As Integer
Private Sub Command1 Click()
Dim i As Integer, j As Integer, x As Integer p = True
i = 1
Do While i <= 9 And p p= False
For j = 10 To i + 1 Step -1
If Then '①
k = a(j): a(j) = a(j - 1): a(j - 1) = k: p = True
End If
Next j
i = i + 1
Loop
For i = 1 To 10
List2.AddItem Str(a(i)) Next i
End Sub
Private Sub Form_Load()
Dim i As Integer
List1.Clear
Randomize '初始化随机函数 Rnd
For i = 1 To 10
a(i) = '②
List1.AddItem
Str(a(i))
Next i
End Sub
①{#blank#}1{#/blank#} ②{#blank#}2{#/blank#}