Hide

SftTabs/OCX 6.5 - Tab Control for VB6

Display
Print

Application Notes

Use of References (1)

Individual tabs are represented by the object SftTabsTab. The tab index which is usually used to access a specific tab in the control changes as tabs are inserted and deleted, because the tab index simply describes the position of a tab in the tab control.

Using an object reference, it is possible to add a tab and retrieve its SftTabsTab object. Even if the tab's position changes (i.e. its tab index changes) because other tabs are inserted, the SftTabsTab object reference is still valid and can be used to manipulate the tab. Using the Index property, the tab's index can also be retrieved.

Example

Private Sub Form_Load()
    Dim TabIndex As Integer
    Dim Tab1Object As SftTabsLib.SftTabsTab
    With SftTabs1.Direct
        .Tabs.Clear
        TabIndex = .Tabs.Add("Tab &1")
        Set Tab1Object = .Tab(TabIndex) ' save object reference
        TabIndex = .Tabs.Insert("Tab &0", 0)
        ' now update 'Tab &1'
        Tab1Object.Text = "Hello"
    End With
End Sub

Use of References (2)

If an object is repeatedly manipulated it may be more efficient to save an object reference:

Example

Private Sub Form_Load()
    Dim TabIndex As Integer
    Dim Tab1Object As SftTabsLib.SftTabsTab
    With SftTabs1.Direct
        .Tabs.Clear
        TabIndex = .Tabs.Add("Tab &1")
        Set Tab1Object = .Tab(TabIndex) ' save object reference
        Tab1Object.BackColor = vbWhite
        Tab1Object.BackColorActive = vbWhite
        Tab1Object.ForeColor = vbBlue
        Tab1Object.ForeColorActive = vbBlue
        Tab1Object.Text = "Hello"
    End With
End Sub

The above is more efficient than the following, because here the same SftTabsTab object is repeatedly retrieved:

Private Sub Form_Load()
    Dim TabIndex As Integer
    Dim Tab1Object As SftTabsLib.SftTabsTab
    With SftTabs1.Direct
        .Tabs.Clear
        TabIndex = .Tabs.Add("Tab &1")
        .Tab(TabIndex).BackColor = vbWhite
        .Tab(TabIndex).BackColorActive = vbWhite
        .Tab(TabIndex).ForeColor = vbBlue
        .Tab(TabIndex).ForeColorActive = vbBlue
        .Tab(TabIndex).Text = "Hello"
    End With
End Sub

Last Updated 08/13/2020 - (email)
© 2024 Softel vdm, Inc.