Private Sub Command1_Click ( ?。?br />Dim s As String,resule As String,pos As String Dim count As Integer,i As Integer i=1:count=0 resule=““:pos=““ Do While i<=Len(Text1.Text) s=Mid(Text1.Text,i,Len(Text2.Text)) If s=Text2.Text Then result=result+Text3.Text count=count+1
i=i+Len(Text2.Text) Else
i=i+1 End If Loop Text4.Text=result Text5.Text=Str(count) Text6.Text=pos End Sub.
. (2)請(qǐng)?jiān)跈M線處填入合適的代碼 Dim sName(1to 50)As String‘存放學(xué)生姓名 Dim sScore(1to 50)As Integer’存放學(xué)生分?jǐn)?shù) Dim recount As Integer’存放學(xué)生人數(shù) Private Sub Form_load ( ?。?br />‘本過(guò)程從數(shù)據(jù)庫(kù)中讀取學(xué)生數(shù)據(jù),存儲(chǔ)在相應(yīng)的變量中,并在List1中顯示 ‘代碼略 End Sub ‘整數(shù)轉(zhuǎn)換成長(zhǎng)度固定的字符串 Function ads(x As Integer,n As Integer)As string Dim sx As String,nx As Integer,i As Integer sx=Str(x):nx=Len(sx) For i=1to n-nx sx=””+sx Next i ①
End Function Private Sub Command1_click( ?。?br />Dim A(0to 100)As Integer’存放每個(gè)分?jǐn)?shù)的個(gè)數(shù) Dim B(0to 100)As Integer’存放每個(gè)分?jǐn)?shù)的名次 Dim mc As Integer,score As integer,i As Integer For i=0to 100⑧ A(i)=0 Next i For i=1to recount’計(jì)算每個(gè)分?jǐn)?shù)的個(gè)數(shù) ②
Next i mc=1 For i=100to 0step-1’計(jì)算每個(gè)分?jǐn)?shù)名次 If A(i)<>0Then B(i)=mc ③
End if Next i List2.clear List2.a(chǎn)dditem“姓名 分?jǐn)?shù) 名次” List2.a(chǎn)dditem”--------” For i=1to recount score=sScore(i) mc=B(sScore(i)) list2.a(chǎn)dditem sName(i)+ads(score,5)+”第”+ads(mc,3)+”名” Next i End Sub.