I have two buttons one "prev" and one "next" I want to go through the records of a listbox. When I reach the end I want it to go to the first record.
I appriciate your help
Printable View
I have two buttons one "prev" and one "next" I want to go through the records of a listbox. When I reach the end I want it to go to the first record.
I appriciate your help
VB Code:
Private Sub cmdNext_Click() 'Select Next selection If ListView1.SelectedItem.Index < ListView1.ListItems.Count Then ListView1.ListItems(ListView1.SelectedItem.Index + 1).Selected = True Else ListView1.ListItems(1).Selected = True End If 'Set focus ListView1.SelectedItem.EnsureVisible ListView1.SetFocus End Sub Private Sub cmdPrev_Click() 'Select Prev selection If ListView1.SelectedItem.Index > 1 Then ListView1.ListItems(ListView1.SelectedItem.Index - 1).Selected = True Else ListView1.ListItems(ListView1.ListItems.Count).Selected = True End If 'Set focus ListView1.SelectedItem.EnsureVisible ListView1.SetFocus End Sub