Index Property

Applies To

Page object, Tab object.

Description

The position of a Tab object within a Tabs collection or a Page object in a Pages collection.

Syntax

object.Index [= Integer]

The Index property syntax has these parts:

Part

Description

object

Required. A valid object.

Integer

Optional. The index of the currently selected Tab object.


Remarks

The Index property specifies the order in which tabs appear. Changing the value of Index visually changes the order of Pages in a MultiPage or Tabs on a TabStrip. The index value for the first page or tab is zero, the index value of the second page or tab is one, and so on.

In a MultiPage, Index refers to a Page as well as the page's Tab. In a TabStrip, Index refers to the tab only.

See Also

Pages collection, Tabs collection.

Example

The following example uses the Index property to change the order of the pages and tabs in a MultiPage and TabStrip. The user chooses CommandButton1 to move the third page and tab to the front of the MultiPage and TabStrip. The user chooses CommandButton2 to move the selected page and tab to the back of the MultiPage and TabStrip.

To use this example, copy this sample code to the Declarations portion of a form. Make sure that the form contains:

  • Two CommandButton controls named CommandButton1 and CommandButton2.
  • A MultiPage named MultiPage1.
  • A TabStrip named TabStrip1.
    Dim MyPageOrTab As Object
    
    Private Sub CommandButton1_Click()
    'Move third page and tab to front of control
        MultiPage1.page3.Index = 0
        TabStrip1.Tab3.Index = 0
    End Sub
    
    Private Sub CommandButton2_Click()
    'Move selected page and tab to back of control
        Set MyPageOrObject = MultiPage1.SelectedItem
        MsgBox "MultiPage1.SelectedItem = " & MultiPage1.SelectedItem.Name
        MyPageOrObject.Index = 4
    
        Set MyPageOrObject = TabStrip1.SelectedItem
        MsgBox "TabStrip1.SelectedItem = " & TabStrip1.SelectedItem.Caption
        MyPageOrObject.Index = 4
    End Sub
    
    Private Sub UserForm_Initialize()
        MultiPage1.Width = 200
        MultiPage1.Pages.Add
        MultiPage1.Pages.Add
        MultiPage1.Pages.Add
        
        TabStrip1.Width = 200
        TabStrip1.Tabs.Add
        TabStrip1.Tabs.Add
        TabStrip1.Tabs.Add
        
        CommandButton1.Caption = "Move third page/tab to front"
        CommandButton1.Width = 120
        
        CommandButton2.Caption = "Move selected item to back"
        CommandButton2.Width = 120
    End Sub