實(shí)現(xiàn)上述功能的VB程序如下,但加框處代碼有錯(cuò),請(qǐng)改正. 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 result=““: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 pos=pos+Str(count) i=i+Len(Text2.Text) Else result=result+Text2.Text 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 recCount 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 ( ) 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 recCount'計(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.AddItem“姓名 分?jǐn)?shù) 名次“ List2.AddItem“----------------“ For i=1To recCount score=sScore(i) mc=B(sScore(i)) List2.AddItem sName(i)+ads(score,5)+“第“+ads(mc,3)+“名“ Next i End Sub.