Cycle through some tab contols...

Hello experts,

Part of my interface works by hiding various tabs depending on a user selection.

I've written the following pseudo-code, but i cant find the necessary syntax to actually make it work in
Tabs_FrmMain is a standard tab control.

Sub SelectTabPage(ByVal intPage As Integer)
        If (intPage >= 0 And intPage < Me.Tabs_FrmMain.TabCount()) Then 'tab is in range
            Dim x As Integer
            For x = 0 To Me.Tabs_FrmMain.TabCount() Step 1            
                Me.Tabs_FrmMain.TabPage[x].Visible = False
            Me.Tabs_FrmMain.TabPage[intPage].Visible = True
        Else 'invalid tab selected
        End If
End Sub

any takes?
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

LacutahConnect With a Mentor Commented:
Funny you should ask, I answered this one a few days ago...  Essentially you can't "show" and "hide" tabs inside a tab control (don't know why, but you can't)  However, you can remove them from the tab pages collection and re-add them back later.
mnamiriAuthor Commented:

you said the following in your previous answer... (unfortunately my VB skills still arn't up to speed), but how do you create the array with the tab pages copied into it. etc. i guess what im searching for is a bit or a turn-key solution.

I've run into this too.  TabControls contain TabPages.  The trick is to remove the pages in question, and add them back into the TabControl if needed.

For example:
Private MyHiddenPages as New ArrayList()
Sub From1_Load(...)
      if IsGuesUser then
          'Add page to ArrayList object, so can restore later..
          'Remove page from tabcontrol
      end if
End Sub
All Courses

From novice to tech pro — start learning today.