button properties without clicking on them

Dave S

Newcomer
Joined
Apr 4, 2003
Messages
9
:confused:

Im having trouble again.
Imagine a minefield grid. You have the tab index of the sender.
how can I access the tag property of the adjoining buttons without clicking on them? I would like to use the tab index property of the button.

I was thinking of scrolling through all 100 buttons untill the tabindex matched the index I am interested in, then read the tag, but I don't know how to increment the button names: btn1,btn2, etc.

My brain hurts,
Dave
 
You could go through every button there and find the one with the matching index.
Visual Basic:
        Dim ctrl As Control
        For Each ctrl In Me.Controls
            If TypeOf ctrl Is Button Then
                if ctrl.TabIndex = numberyouwant then
                    'do something to that button
                end if 
            End If
        Next
 
Or a simpler way of which i didn't think when writing my first post :D
Before the code checked every control if its button. Now you it will only go through buttons. (So it should be better :) )
Visual Basic:
        Dim btn As Button
        For Each btn In Me.Controls
            If btn.TabIndex = numberyouwant Then
                'do something to the button
            End If
        Next
 
Back
Top