实现上述功能的VB程序如下。
Private Sub Command1_Click()
Dim s As String, i As Integer, j As Integer, s1 As String
Dim a(30) As Integer, max As Integer, c As String, sum As Integer
s=Text1.Text
i=1:t=0:sum=0
Do While i <= Len(s)
c=Mid(s, i, 1)
If c=“,” Or ① Then
a(t)=a(t)+1
t=0
sum=sum+1
Else
′改错
End If
i=i+1
Loop
max=a(1)
For i=1 To 30
List1.AddItem “编号为”+Str(i)+ “的教师,得票数为”+Str(a(i))
If max < a(i) Then
max=a(i)
s1=“最高教师编号为:”+Str(i)
②
s1=s1+”,”+Str(i)
End If
Next i
Text2.Text=Str(sum)
Text3.Text=Str(max)
Label2.Caption=s1
End Sub
① ②