小王基于选择排序算法编写了一个VB程序,功能如下:在文本框Text1中显示排序前的数据,单击“排序”按钮,在文本框Text2中显示剔除重复数据后的升序排序结果。程序运行界面如图所示。
实现上述功能的VB代码如下,请回答下列问题:
Const n= 10
Dim a(1 To n) As Integer
Private Sub Form_ load( )
'数组初始化,生成1~20之间的随机整数并赋值给数组a,代码略
End Sub
Private Sub Cmd1_Click()
Dim i As Integer, j As Integer, t As Integer
Dim bottom As Integer
bottom= n
For i=1 To bottom-1
For j= bottom To i+1 Step -1
If Then '①改错
t=a(j) : a(j)=a(i) : a(i)=t
ElselIf a(j)=a(i) Then
'②填空
bottom= bottom- 1
End If
Next j
Next i
Text2. Text=" "
For i=1 To bottom
Text2. Text= Text2. Text+Str(a(i))
Next i
End Sub