spin up / spin down

J

JT

I have 2 listboxes (LB1 and LB2) side by side on a form. There are over 300
items in each list box. Each list box has been loaded. Now I would like to
use a spin button to move up and down through each list box. Any help on
getting started with the code to move up and down through the list boxes
would be GREATLY appreciated. Thanks for all of the help........

FYI...there are 6 columns of various length in each list box. Does this
make a difference? I'm considering combining my data for each row into a
single column. Do I need to do that to use a spin button?
 
T

Tom Ogilvy

Private Sub SpinButton1_SpinDown()
With ListBox1
If .ListIndex < .ListCount - 1 Then
.ListIndex = .ListIndex + 1
End If
End With
End Sub

Private Sub SpinButton1_SpinUp()
With ListBox1
If .ListIndex > 0 Then
.ListIndex = .ListIndex - 1
End If
End With
End Sub

worked for me. Adjust it to handle two listboxes.
 
J

JT

Thank You very much.......It is working exactly like I want it to.

One more question.......is it possible to highlight the first row in each
listbox when the form opens and then move the highlighted row either up or
down with the spin button?

Thanks again for all of the help..
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top