實現上述功能的VB程序如下: (1)請在橫線處填入合適代碼. Dim a(1To 8)As Integer'存儲道次編號 Dim b(1To 8)As Single'存儲運動員成績 Dim num As Integer Private Sub Command1_Click ( ?。?br />Dim i As Integer,j As Integer,k As Integer,p As Integer Dim t As Single For i=1To 7 k=i For j=i+1To 8 If
Then k=j End If Next j If k<>i Then p=a(i):a(i)=a(k):a(k)=p t=b(i):b(i)=b(k):b(k)=t End If Next i For i=1To 8 List2.AddItem Str(a(i)) &“道:“& Str(b(i)) Next i End Sub Private Sub Text1_KeyPress(KeyAscii As Integer)'按回車鍵錄入比賽成績 Dim cj As Single If KeyAscii=13Then num=num+1 cj=Val(Text1.Text) If cj>0And num<=8Then a(num)=num
List1.AddItem Str(a(num)) &“道:“& Str(b(num)) Else MsgBox“輸入無效“ End If Text1.Text=““ End If End Sub (2)在Command1_Click
。 (2)請在橫線處填入合適的代碼。 Function check(s As String) As Integer Dim i As Integer,g1As Integer,g2As Integer,g3As Integer Dim c(1To 7)As Integer For i=1To 7 c(i)=Val(Mid(s,i,1)) Next i g1=c(1)Xor c(3)Xor c(5)Xor c(7) g2=c(2)Xor c(3)Xor c(6)Xor c(7) g3=c(4)Xor c(5)Xor c(6)Xor c(7) If g1+g2+g3=0Then check=0Else check=
End Function Private Sub Command1_Click ( ?。?br />Dim i As Integer,m As Integer,Outs As String m=
If m=0Then Text2.Text=“驗證正確,數據無錯誤“ Else For i=1To 7 If i=m Then Outs=Outs+Chr( Asc(Mid(Text1.Text,i,1)) Xor
) Else Outs=Outs+Mid(Text1.Text,i,1) End If Next i Text2.Text=“第“+Str(m)+“位上數據有錯誤,正確編碼應為:“+Outs End If End Sub