我单击命令按钮,以便可以添加列表视图项,列表视图项来自命令框,并且我想对其进行msgbox或将其打印在标签上
这是出于教育目的
Private Sub Command1_Click()
List1.AddItem (Combo1.Text)
If List1.ListCount > 2 Then
MsgBox "error"
Else
MsgBox 'add the 3 number and print it out
End If
End Sub
我希望列表视图中的3个数字相加,以便以消息框的形式打印该值
答案 0 :(得分:0)
尝试一下
Private Sub CommandButton1_Click()
Dim tempSum As Long
Dim i As Long
List1.AddItem (Combo1.Text)
If List1.ListCount = 3 Then
For i = 0 To List1.ListCount - 1
tempSum = tempSum + List1.List(i)
Next
MsgBox "Sum of list: " & tempSum
End If
End Sub