Private Sub Command1_Click()
Dim i As Integer, m As Integer, f As Integer, tmp As String, flag As Boolean
Dim s As String, ch As String, sex As Integer, cm As Integer, cf As Integer
k = 0: sex = 0: m = 0: f = 0
s = Text1.Text
For i = 1 To Len(s) - 1
ch = Mid(s, i, 1)
If ch = "," And Mid(s, i + 1, 1) = "男" Then
tmp = Mid(s, i + 3, 3)
sex = 1
flag = True
ElseIf ch = "," And Mid(s, i + 1, 1) = "女" Then
tmp = Mid(s, i + 3, 3)
cf = cf + 1
flag = True
End If
If flag = True Then
m = m + sex * Val(tmp)
f =
sex = 0
i = i + 5
End If
Next i
Label1.Caption = "男生平均身高:" + Str(m / cm) + "女生平均身高:" + Str(f / cf)
End Sub