Public Class Form1

    Private vName As String

    Private orderVal As String

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        orderVal = "ASC"

        Me.Label1.Text = "TabIndex and TabStop Demo -- ASC"

        Button1.TabStop = False

        Button2.TabStop = False

        Button4.TabStop = False

        Button7.TabStop = False

        Button11.TabStop = False

        Button12.TabStop = False

        Button15.TabStop = False

        Button18.TabStop = False

        Button3.Select()

    End Sub

    Private Sub Button3_GotFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button3.GotFocus

        vName = Button3.Text

        Me.Label17.Text = vName

    End Sub

    Private Sub Button5_GotFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button5.GotFocus

        vName = Button5.Text

        Me.Label17.Text = vName

    End Sub

    Private Sub Button6_GotFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button6.GotFocus

        vName = Button6.Text

        Me.Label17.Text = vName

    End Sub

    Private Sub Button8_GotFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button8.GotFocus

        vName = Button8.Text

        Me.Label17.Text = vName

    End Sub

    Private Sub Button9_GotFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button9.GotFocus

        vName = Button9.Text

        Me.Label17.Text = vName

    End Sub

    Private Sub Button10_GotFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button10.GotFocus

        vName = Button10.Text

        Me.Label17.Text = vName

    End Sub

    Private Sub Button16_GotFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button16.GotFocus

        vName = Button16.Text

        Me.Label17.Text = vName

    End Sub

    Private Sub Button13_GotFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button13.GotFocus

        vName = Button13.Text

        Me.Label17.Text = vName

    End Sub

    Private Sub Button14_GotFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button14.GotFocus

        vName = Button14.Text

        Me.Label17.Text = vName

    End Sub

    Private Sub Button17_GotFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button17.GotFocus

        vName = Button17.Text

        Me.Label17.Text = vName

    End Sub

 

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

        Me.Close()

    End Sub

 

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        If Me.orderVal = "ASC" Then

            Me.Button3.TabIndex = 10

            Me.Button5.TabIndex = 9

            Me.Button6.TabIndex = 8

            Me.Button8.TabIndex = 7

            Me.Button9.TabIndex = 6

            Me.Button10.TabIndex = 5

            Me.Button13.TabIndex = 4

            Me.Button14.TabIndex = 3

            Me.Button16.TabIndex = 2

            Me.Button17.TabIndex = 1

            Me.Button17.Select()

            orderVal = "DES"

            Me.Label1.Text = "TabIndex and TabStop Demo -- DES"

        Else

            Me.Label1.Text = "TabIndex and TabStop Demo -- ASC"

            Me.Button3.TabIndex = 1

            Me.Button5.TabIndex = 2

            Me.Button6.TabIndex = 3

            Me.Button8.TabIndex = 4

            Me.Button9.TabIndex = 5

            Me.Button10.TabIndex = 6

            Me.Button13.TabIndex = 7

            Me.Button14.TabIndex = 8

            Me.Button16.TabIndex = 9

            Me.Button17.TabIndex = 10

            Me.Button3.Select()

            orderVal = "ASC"

 

        End If

    End Sub

End Class