Private Sub Cmd1_Click()
Dim s As String, s1 As String, t As Integer, i As Integer
Dim k As Integer, bh As Integer, w As Integer
Dim w1 As Integer, w2 As Integer
s = Text1.Text: k = 1: t = 0: bh = 0 'bh存储当前垃圾的垃圾编号
w1 = 0: w2 = 0
For i = 1 To Len(s) s1 = Mid(s, i, 1)
If Then
t = t * 10 + Val(s1)
Else
If Then
bh = t
Else
If bh = 1 Then
w1 = w1 + t
Else
w2 = w2 + t
End If
End If
k = k + 1
End If
Next i
List1.AddItem "干垃圾共" + Str(w1) + "斤"
List1.AddItem "湿垃圾共" + Str(w2) + "斤"
Label3.Caption = "总重量共有" + Str(w) + "斤"
End Sub