Take the 2-minute tour ×  I made a form with 10 listboxes. I
want to give focus to a listbox of my choosing. For example, if
i choose the integer "3" it will put focus on the listbox whose
tabindex = 3.  How do I do this?  I thought this might work but
it doesn't:  Dim lst As VB.ListBox: Set lst =
Form.Controls(lst.TabIndex = 3) share|improve this question add
comment  1 Answer  up vote 1 down vote accepted  Do you have a
control array for your list boxes? If so, you can simply do
this:   The above code will only work properly for you if the
List boxes are a control array and you have the tab indexes set
in the same order that you placed the list boxes on the screen.
Otherwise, you can try this code:  Dim oControl As Control Dim
YourNumber As Integer  YourNumber = 4  For Each oControl In
Me.Controls     If oControl.TabIndex = YourNumber Then
Exit For     End If  This code will loop through all the
controls on your form and actively search for the one that
matches your tab index. Once the control is f