(2)
实现上述功能的VB程序如下,请在划线处填入合适的代码。
Const
maxn=10
Dim
a(1 To maxn) As Integer
Private
Sub Form_Load()
‘maxn个数据存储在数组a中,并在列表框List1中显示
‘代码略
End
Sub
Private
Sub Command1_Click()
Dim
i As Integer, n As Integer ‘n用于存储当前査找的数组长度
Dim
j As Integer, key As Integer ‘key用于存储本次查找关键字的数据位置
key=1:
n=maxn
Do
While key <=n
i=n
Do While a(i) <> a(key)
________
Loop
If i=key Then ‘未找到,重新下一査找关键字
key=key+1
Else ‘找到重复数据,删除
For j=i To n-1
________
Next j
n=n-1
End If
Loop
For
i=1 To n
List2.AddItem Str(a(i))
Next
i
Label1.Caption=“共删除数据”+________+“个”
End
Sub