Quantcast
Channel: VBForums
Viewing all articles
Browse latest Browse all 15765

How to add the value of multi-selected list box vba

$
0
0
I need help in getting the sum of the selected values in a listbox(multi-select). Can someone show me a code where I can easily add the value of the selected and enter the value in a textbox. I was able to make a sample for this one, so when I select multiple data from the listbox, it will automatically add the numbers and the number will be on a specific text field. I made something but it's on a message box and it doesn't add the sum of all the numbers that were selected. I have two text fields the 1st one (Total Deductions) is for the sum of the numbers selected from the listbox and the 2nd (Number of Errors) text field is to count the selected data from the listbox. Please see below for the code and for the actual form:

Quote:

Private Function GetSelectedItems() As String
Dim text As String
Dim ir As Integer
For ir = 0 To Me.lboxSelectInstance.ListCount - 1
If Me.lboxSelectInstance.Selected(ir) Then
text = text & Me.lboxSelectInstance.List(ir) & vbNewLine
End If
Next ir
MsgBox "Selected items are: " & text
GetSelectedItemsText = text

End Function

Name:  win.jpg
Views: 38
Size:  30.5 KB
Attached Images
 

Viewing all articles
Browse latest Browse all 15765


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>