下列VB程序的功能是:程序運(yùn)行時(shí),單擊命令按鈕Commandl后,產(chǎn)生10個(gè)[1,999]范圍內(nèi)互不相同的隨機(jī)整數(shù),依次顯示在列表框List1中,然后將它們按從小到大的順序排序,排序結(jié)果顯示在列表框List2中.?dāng)?shù)組a用于存儲(chǔ)產(chǎn)生的10個(gè)隨機(jī)整數(shù),變量f用于標(biāo)記隨機(jī)整數(shù)x與已生成的整數(shù)是否有重復(fù),如有則為True,沒有則為False. 為實(shí)現(xiàn)上述功能,請(qǐng)?jiān)跈M線處填入合適的代碼. Dim a(1To 10)As Integer Private Sub Command1_Click ( ?。?br />Dim n As Integer'n用于統(tǒng)計(jì)已經(jīng)產(chǎn)生的隨機(jī)整數(shù)個(gè)數(shù) Dim i As Integer,j As Integer Dim x As Integer,k As Integer Dim f As Boolean Randomize n=0 List1.Clear List2.Clear Do While n<10 x=
Int(Rnd*999)+1
Int(Rnd*999)+1
'產(chǎn)生[1,999]范圍內(nèi)的隨機(jī)整數(shù) f=False For i=1To n If
x=a(i)
x=a(i)
Then f=True Next i If f=False Then n=n+1 a(n)=x List1.AddItem Str(a(n)) End If Loop For i=1To 9 For j=10To i+1Step-1 If
a(j)<a(j-1)
a(j)<a(j-1)
Then k=a(j):a(j)=a(j-1):a(j-1)=k End If Next j Next i For i=1To 10 List2.AddItem Str(a(i)) Next i End Sub.