vb listbox 复选框选中多项进行计算
4个回答
展开全部
Private Sub Command1_Click()
Dim i As Integer, x As Long
For i = 0 To List1.ListCount - 1
If List1.Selected(i) Then
x = x + Val(List1.List(i))
End If
Next
MsgBox x
End Sub
Private Sub Form_Load()
Dim i As Integer
For i = 100 To 150
List1.AddItem i
Next
End Sub
Dim i As Integer, x As Long
For i = 0 To List1.ListCount - 1
If List1.Selected(i) Then
x = x + Val(List1.List(i))
End If
Next
MsgBox x
End Sub
Private Sub Form_Load()
Dim i As Integer
For i = 100 To 150
List1.AddItem i
Next
End Sub
追答
金额放入.ItemData()
Private Sub Command1_Click()
Dim i As Integer, x As Long
For i = 0 To List1.ListCount - 1
If List1.Selected(i) Then
x = x + Val(List1.ItemData(i))
End If
Next
MsgBox x
End Sub
Private Sub Form_Load()
Dim i As Integer
For i = 100 To 150
List1.AddItem i
List1.ItemData(i - 100) = i - 100
Next
End Sub
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
能详细描述一下吗?
追问
里面有多条数据,选中其中的几条,然后计算总数!
序号 金额
1 5
2 3
3 6
我只是选择1和3的单据号进行计算!
追答
'Text1是张数,Text2是金额
Private Sub Command1_Click()
Dim i, n, sum As Long
For i = 0 To List1.ListCount - 1
If List1.Selected(i) Then sum = sum + Val(List1.List(i)): n = n + 1
Next
Text1 = n
Text2 = sum
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询