小陈设计了VB程序用于解决该问题。程序运行时,在文本框Text1中输入学生的体重数据,用“,”号隔开。在文本框Text2中输入船的最大载重m。单击“计算”按钮Command1,读取学生体重数据到数组a中,并在标签Label1中显示最少分组数。程序运行界面如图所示。请回答下列问题:
Private Sub Command1_Click()
Dim a(1 To 40) As Integer
Dim n As Integer, m As Integer
Dim t As Integer
Dim sum As Integer, c As Integer
Dim s As String, ch As String,
n = 0 : t = 0
s = Text1.Text
m = Val(Text2.Text)
For i = 1 To Len(s)
ch = Mid(s,i,1)
If ch <> "," Then
Else
n = n + 1
a(n) = t
t = 0
End If
Next i
sum = 0 : c = 0
For i = 1 To n
If Then
sum = 0 : c = c + 1
End If
sum = sum + a(i)
Next i
Label1.Caption = "最少分组:" + c
End Sub