實(shí)現(xiàn)上述功能的VB代碼如下,但加框處代碼有錯(cuò),請(qǐng)改正. Private Sub Command1_Click ( ?。?br />Dim a As String,b As String Dim i As Integer,c As String a=Text1.Text For i=1To Len(a) c=Mid(a,i,1)
b=upcase(c)+b'(1) Next i
Text2.Text=Str(b)'(2) End Sub '將小寫(xiě)字母轉(zhuǎn)換為大寫(xiě)字母 Private Function upcase(c As String) As String If c>=“a“And c<=“z“Then upcase=Chr(Asc(c)-32) Else upcase=c End If End Function.
17.下列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ù),如有則為T(mén)rue,沒(méi)有則為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=
'產(chǎn)生[1,999]范圍內(nèi)的隨機(jī)整數(shù) f=False For i=1To n If
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
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.