Results 1 to 6 of 6
  1. #1
    Silver Lounger
    Join Date
    Jun 2002
    Location
    Cheadle, Staffordshire
    Posts
    2,177
    Thanks
    0
    Thanked 0 Times in 0 Posts

    TabStrip Control or Tabbed Control (VB6)

    I've not used the tab controls before, so I'm just having a little play with them.

    On a form I have put one of each, just for testing, and with each, if I try to add code to the click event of the tab I don't have much success.
    What is the correct way to add code to a tab so I can test it.

    The properties return:

    <pre>Private Sub SSTab1_DblClick()</pre>


    and

    <pre>Private Sub TabStrip1_Click()</pre>


    But this is for the whole control and not for individual tabs.
    So I thought, I must reference the code via the tabs index, ie:

    <pre>Private Sub SSTab1_DblClick()
    Dim index As Integer
    Select Case index
    Case 1
    MsgBox index
    BtnClick "C:fm_EstimatesAuthorised"
    Case 2
    MsgBox index
    BtnClick "C:fm_EstimatesunAuthorised"
    End Select
    End Sub</pre>


    and

    <pre>Private Sub TabStrip1_Click()
    Dim index As Integer
    Select Case index
    Case 1
    MsgBox index
    BtnClick "C:fm_EstimatesAuthorised"
    Case 2
    MsgBox index
    BtnClick "C:fm_EstimatesunAuthorised"
    End Select
    End Sub</pre>


    But neither works.
    This is only for testing at the moment so help would be appreciated.

    BtnClick :

    <pre>Private Sub BtnClick(strPath As String)

    Dim fso As New Scripting.FileSystemObject
    Dim fld As Scripting.Folder
    Dim fil As Scripting.File

    Set fld = fso.GetFolder(strPath)

    Me.MousePointer = vbHourglass
    Me.lstFolders.Clear
    Me.txtPath.Text = fld & ""
    For Each fil In fld.Files
    If Right(fil, 4) = ".EST" Then
    Me.lstFolders.AddItem fil.Name
    End If
    Next fil
    Set fil = Nothing
    Set fld = Nothing
    Set fso = Nothing
    Me.MousePointer = vbDefault

    End Sub</pre>


  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: TabStrip Control or Tabbed Control (VB6)

    The Index property has a special meaning in VB6. You can create a control array: a series of controls of the same type. The Index property is used to refer to a specific member of the control array. So Index does not have anything to do with the active tab of a tabstrip.

    You used the On Dbl Click event of the SSTab, you probably want the On Click event. You can use the Tab property to return/set the active tab (zero-based):

    Private Sub SSTab1_Click(PreviousTab As Integer)
    Select Case SSTab1.Tab
    Case 0

  3. #3
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: TabStrip Control or Tabbed Control (VB6)

    You don't seem to assign a value to Index before you start using it. Did you mean to use SSTab1.SelectedItem?

    StuartR

  4. #4
    Silver Lounger
    Join Date
    Jun 2002
    Location
    Cheadle, Staffordshire
    Posts
    2,177
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: TabStrip Control or Tabbed Control (VB6)

    Like this :

    <pre>Private Sub Form_Load()

    SelectedTab = 1
    TabStrip1.SelectedItem = TabStrip1.Tabs(SelectedTab)

    End Sub


    Private Sub TabStrip1_Click()

    SelectedTab = TabStrip1.SelectedItem.index

    Select Case SelectedTab

    Case 1
    BtnClick "C:fm_EstimatesAuthorised"
    Case 2
    BtnClick "C:fm_EstimatesunAuthorised"
    Case 3
    BtnClick "C:fm_EstimatesSaved"
    Case 4
    BtnClick "C:fm_EstimatesRejected"
    Case 5
    BtnClick "C:fm_EstimatesAwaiting Inspection"
    Case 6
    BtnClick "C:fm_EstimatesExported"
    Case 7
    BtnClick "C:fm_EstimatesImages"
    Case 8
    BtnClick "C:fm_EstimatesInvoices"
    Case 9
    BtnClick "C:fm_EstimatesNotification"
    Case 10
    BtnClick "C:fm_EstimatesSent"
    Case 11
    BtnClick "C:fm_EstimatesTotal Loss"

    End Select


    End Sub</pre>


  5. #5
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: TabStrip Control or Tabbed Control (VB6)

    Umm, is this a further question, or does it work now?

  6. #6
    Silver Lounger
    Join Date
    Jun 2002
    Location
    Cheadle, Staffordshire
    Posts
    2,177
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: TabStrip Control or Tabbed Control (VB6)

    Hans

    Yes it works fine, no errors either..
    I googled to find a tutorial and adapted it to suit my example.

    Thanks Hans and StuartR

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •