Private Sub Form_Load()
ControlTabs Me, TabStrip1, TabStrip1.SelectedItem.Index
End Sub
Private Sub TabStrip1_Click()
ControlTabs Me, TabStrip1, TabStrip1.SelectedItem.Index
End Sub
Private Sub ControlTabs(ByVal oForm As Form, _
ByVal oTabStrip As TabStrip, _
ByVal iTabIndex As Integer)
'======================================================================
'Description :Handles visibility of frames within a
' TabStrip control.
' This sub requires number of frames =
' number of tabs.
'Parameters :oForm = Name of parent form;
' oTabStrip = Name of TabStrip control;
' iTabIndex = Tab index.
'Variables :iTabCnt = Number of tabs in TabStrip
' control;
' iCntFrames = Number of frames on form.
'Author :E.Groen / www.yachtgroup.com
'Date :13.04.2001
'Changed :-
'======================================================================
Dim iTabCnt, iCntFrames As Integer
On Error GoTo Error_ControlTabs
'[Frame = 0 based, TabStrip = 1 based therefore:
' equalize].
iTabCnt = (oTabStrip.Tabs.Count - 1)
iTabIndex = (iTabIndex - 1)
'[Loop through the indexes of the Frame control on your
' parent
'Form. If this index matches the number of the selected
' tab then
'leave only this tab visible].
For iCntFrames = 0 To iTabCnt
oForm.Frame1(iCntFrames).Visible = False
If iCntFrames = iTabIndex Then _
oForm.Frame1(iCntFrames).Visible = True
Next iCntFrames
Exit Sub
Error_ControlTabs:
'[Raise error when number of Frames <> number of tabs
'else catch other error].
Select Case Err.Number
Case 340: MsgBox "Frame index(" & iCntFrames & ") " & _
"doesn't exist in the ControlArray." & _
vbCrLf & "Make sure you add this frame to " & _
"your TabStrip control.", _
vbCritical, "Error " & Err.Number
Case Else: MsgBox Err.Description, vbCritical, _
"Error " & Err.Number
End Select
End Sub
|