Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Need to capture the values in a ListView Box using MultiSelect....

skiballskiball Posts: 7Member
Yes it's me again. Just wanted to say this is a great msgboard. I'm very happy with some of the solutions i recieved from here but i have another question.

Just to let you guys/women know i only been doing this for a year so i might have alot of questions that might seem obvious to others. Thanks,

OK
I have a list box and the user can choose either 1 item or multiple items. If it's multiple items then i want to select just whats selected or highlighted. I would like to run an action on all the items that are in the highlighted group or multiselected. Basically my code goes through the list wheither or not it's selected. Need Help Please!!!!

Private Sub cmdASV_Click()
Dim i As Integer

For i = 1 To lvDoc.ListItems.Count 'This loops through the List box.

If lvDoc.ListItems.Selected Then
msgbox "Test"
End If

Next i

End Sub

Comments

  • BitByBit_ThorBitByBit_Thor Posts: 2,444Member
    : Yes it's me again. Just wanted to say this is a great msgboard. I'm very happy with some of the solutions i recieved from here but i have another question.
    :
    : Just to let you guys/women know i only been doing this for a year so i might have alot of questions that might seem obvious to others. Thanks,
    :
    : OK
    : I have a list box and the user can choose either 1 item or multiple items. If it's multiple items then i want to select just whats selected or highlighted. I would like to run an action on all the items that are in the highlighted group or multiselected. Basically my code goes through the list wheither or not it's selected. Need Help Please!!!!
    :
    : Private Sub cmdASV_Click()
    : Dim i As Integer
    :
    : For i = 1 To lvDoc.ListItems.Count 'This loops through the List box.
    :
    : If lvDoc.ListItems.Selected Then
    : msgbox "Test"
    : End If
    :
    : Next i
    :
    : End Sub
    :

    By default, all index values in VB go from 0 To Count - 1
    So your loop would be:
    For i = 0 To lvDoc.ListItems.Count - 1


    Greets...
    Richard

  • BitByBit_ThorBitByBit_Thor Posts: 2,444Member
    : : Yes it's me again. Just wanted to say this is a great msgboard. I'm very happy with some of the solutions i recieved from here but i have another question.
    : :
    : : Just to let you guys/women know i only been doing this for a year so i might have alot of questions that might seem obvious to others. Thanks,
    : :
    : : OK
    : : I have a list box and the user can choose either 1 item or multiple items. If it's multiple items then i want to select just whats selected or highlighted. I would like to run an action on all the items that are in the highlighted group or multiselected. Basically my code goes through the list wheither or not it's selected. Need Help Please!!!!
    : :
    : : Private Sub cmdASV_Click()
    : : Dim i As Integer
    : :
    : : For i = 1 To lvDoc.ListItems.Count 'This loops through the List box.
    : :
    : : If lvDoc.ListItems.Selected Then
    : : msgbox "Test"
    : : End If
    : :
    : : Next i
    : :
    : : End Sub
    : :
    :
    : By default, all index values in VB go from 0 To Count - 1
    : So your loop would be:
    : For i = 0 To lvDoc.ListItems.Count - 1
    :
    :
    : Greets...
    : Richard
    :
    :

    Btw, which version of VB are you using?
    I am currently using VB6, and with the standard ListBox control, there is no property called ListItems...
    There you have to use a combination of Selected(Index), List(Index) for the value and ListCount


    Greets...
    Richard

  • skiballskiball Posts: 7Member
    : : : Yes it's me again. Just wanted to say this is a great msgboard. I'm very happy with some of the solutions i recieved from here but i have another question.
    : : :
    : : : Just to let you guys/women know i only been doing this for a year so i might have alot of questions that might seem obvious to others. Thanks,
    : : :
    : : : OK
    : : : I have a list box and the user can choose either 1 item or multiple items. If it's multiple items then i want to select just whats selected or highlighted. I would like to run an action on all the items that are in the highlighted group or multiselected. Basically my code goes through the list wheither or not it's selected. Need Help Please!!!!
    : : :
    : : : Private Sub cmdASV_Click()
    : : : Dim i As Integer
    : : :
    : : : For i = 1 To lvDoc.ListItems.Count 'This loops through the List box.
    : : :
    : : : If lvDoc.ListItems.Selected Then
    : : : msgbox "Test"
    : : : End If
    : : :
    : : : Next i
    : : :
    : : : End Sub
    : : :
    : :
    : : By default, all index values in VB go from 0 To Count - 1
    : : So your loop would be:
    : : For i = 0 To lvDoc.ListItems.Count - 1
    : :
    : :
    : : Greets...
    : : Richard
    : :
    : :
    :
    : Btw, which version of VB are you using?
    : I am currently using VB6, and with the standard ListBox control, there is no property called ListItems...
    : There you have to use a combination of Selected(Index), List(Index) for the value and ListCount
    :
    :
    : Greets...
    : Richard
    :
    :
    Thanks for the Help. I'm using VB6 BTW, The code codes thru the list which is great! I tried several ways to try just to grab what's highlighted and run some action on those. From what i have here it catches the number of items that are highlighlighted (Yes!) but it starts from the last one thats selected from the list and runs the action from the last and forward. (e.g. 6 Docs Total, 1-3 are highlighted but the actions from item 3 - 5). Thanks again PH.

    For i = 1 To lvDoc.ListItems.Count - 1

    If lvDoc.SelectedItem.Selected = True Then
    'If lvDoc.SelectedItem = True Then
    'If lvDoc.SelectedItem.Index Then
    'If lvDoc.SelectedItem.Selected Then
    'For i = 0 To lvDoc.ListItems.Count

    Call ReprintCurrentDoc(sReprint)
    End If

    Next i
  • skiballskiball Posts: 7Member
    : : : : Yes it's me again. Just wanted to say this is a great msgboard. I'm very happy with some of the solutions i recieved from here but i have another question.
    : : : :
    : : : : Just to let you guys/women know i only been doing this for a year so i might have alot of questions that might seem obvious to others. Thanks,
    : : : :
    : : : : OK
    : : : : I have a list box and the user can choose either 1 item or multiple items. If it's multiple items then i want to select just whats selected or highlighted. I would like to run an action on all the items that are in the highlighted group or multiselected. Basically my code goes through the list wheither or not it's selected. Need Help Please!!!!
    : : : :
    : : : : Private Sub cmdASV_Click()
    : : : : Dim i As Integer
    : : : :
    : : : : For i = 1 To lvDoc.ListItems.Count 'This loops through the List box.
    : : : :
    : : : : If lvDoc.ListItems.Selected Then
    : : : : msgbox "Test"
    : : : : End If
    : : : :
    : : : : Next i
    : : : :
    : : : : End Sub
    : : : :
    : : :
    : : : By default, all index values in VB go from 0 To Count - 1
    : : : So your loop would be:
    : : : For i = 0 To lvDoc.ListItems.Count - 1
    : : :
    : : :
    : : : Greets...
    : : : Richard
    : : :
    : : :
    : :
    : : Btw, which version of VB are you using?
    : : I am currently using VB6, and with the standard ListBox control, there is no property called ListItems...
    : : There you have to use a combination of Selected(Index), List(Index) for the value and ListCount
    : :
    : :
    : : Greets...
    : : Richard
    : :
    : :
    : Thanks for the Help. I'm using VB6 BTW, The code codes thru the list which is great! I tried several ways to try just to grab what's highlighted and run some action on those. From what i have here it catches the number of items that are highlighlighted (Yes!) but it starts from the last one thats selected from the list and runs the action from the last and forward. (e.g. 6 Docs Total, 1-3 are highlighted but the actions from item 3 - 5). Thanks again PH.
    :
    : For i = 0 To lvDoc.ListItems.Count - 1
    :
    : If lvDoc.SelectedItem.Selected = True Then
    : 'If lvDoc.SelectedItem = True Then
    : 'If lvDoc.SelectedItem.Index Then
    : 'If lvDoc.SelectedItem.Selected Then
    : 'For i = 0 To lvDoc.ListItems.Count
    :
    : Call ReprintCurrentDoc(sReprint)
    : End If
    :
    : Next i
    :

  • skiballskiball Posts: 7Member
    : : : : : Yes it's me again. Just wanted to say this is a great msgboard. I'm very happy with some of the solutions i recieved from here but i have another question.
    : : : : :
    : : : : : Just to let you guys/women know i only been doing this for a year so i might have alot of questions that might seem obvious to others. Thanks,
    : : : : :
    : : : : : OK
    : : : : : I have a list box and the user can choose either 1 item or multiple items. If it's multiple items then i want to select just whats selected or highlighted. I would like to run an action on all the items that are in the highlighted group or multiselected. Basically my code goes through the list wheither or not it's selected. Need Help Please!!!!
    : : : : :
    : : : : : Private Sub cmdASV_Click()
    : : : : : Dim i As Integer
    : : : : :
    : : : : : For i = 1 To lvDoc.ListItems.Count 'This loops through the List box.
    : : : : :
    : : : : : If lvDoc.ListItems.Selected Then
    : : : : : msgbox "Test"
    : : : : : End If
    : : : : :
    : : : : : Next i
    : : : : :
    : : : : : End Sub
    : : : : :
    : : : :
    : : : : By default, all index values in VB go from 0 To Count - 1
    : : : : So your loop would be:
    : : : : For i = 0 To lvDoc.ListItems.Count - 1
    : : : :
    : : : :
    : : : : Greets...
    : : : : Richard
    : : : :
    : : : :
    : : :
    : : : Btw, which version of VB are you using?
    : : : I am currently using VB6, and with the standard ListBox control, there is no property called ListItems...
    : : : There you have to use a combination of Selected(Index), List(Index) for the value and ListCount
    : : :
    : : :
    : : : Greets...
    : : : Richard
    : : :
    : : :
    : : Thanks for the Help. I'm using VB6 BTW, The code codes thru the list which is great! I tried several ways to try just to grab what's highlighted and run some action on those. From what i have here it catches the number of items that are highlighlighted (Yes!) but it starts from the last one thats selected from the list and runs the action from the last and forward. (e.g. 6 Docs Total, 1-3 are highlighted but the actions from item 3 - 5). Thanks again PH.
    : :
    : : For i = 0 To lvDoc.ListItems.Count - 1
    : :
    : : If lvDoc.SelectedItem.Selected = True Then
    : : 'If lvDoc.SelectedItem = True Then
    : : 'If lvDoc.SelectedItem.Index Then
    : : 'If lvDoc.SelectedItem.Selected Then
    : : 'For i = 0 To lvDoc.ListItems.Count
    : :
    : : Call ReprintCurrentDoc(sReprint)
    : : End If
    : :
    : : Next i
    : :
    :
    :

Sign In or Register to comment.