TabStripSample




Option Explicit
Private Sub cmdexit_Click()
Unload Me
End Sub
'_________________________________________________________


Private Sub Form_Load()
On Error Resume Next
Dim x As Integer
'At design time you would move your containers off

'to -20000 or some other odd number so you can work

'with one container at a time. do this so in design

'mode you dont have to worry about movin things around


Me.Move 0, 0, 4900, 3375 'set StartUpPos Property to 2, or specify left and top
For x = 0 To tbsExample.Tabs.Count - 1 'Loop through the tabs
'subtract 1 if your containers are 0 based otherwise dont subtract 1

'by default tab strips are 1 based

'FYI : A tabstrip uses the collection properties of vb

With Picture1(x)
.BorderStyle = 0
.Visible = False
.Move tbsExample.ClientLeft, tbsExample.ClientTop, tbsExample.ClientWidth, tbsExample.ClientHeight
End With
Next x
'first tab is selected by default, if you want a different tab select

'uncomment below, and change the index value of the container

'tbsExample.Tabs(1).Selected = True Form loads With first tab selected

Picture1(0).Visible = True 'Show first container
End Sub
'_________________________________________________________


Private Sub tbsExample_Click()
Dim intSelTab As Integer
Static intCurTab As Integer
intSelTab = tbsExample.SelectedItem.Index - 1
'current tab = selected tab dont waste time showing the same tab

If intCurTab = intSelTab Then Exit Sub
intCurTab = intSelTab 'save new tab
'NOTE: This could be done simpler but it does not lend itself

'to be maintained.

Select Case intSelTab
Case 0 'Tab #1,usually you would put more descriptive text
Picture1(0).Visible = True
Picture1(1).Visible = False
Picture1(2).Visible = False
Picture1(3).Visible = False
lblMsg = "Tab #1"
Case 1 'Tab #2
Picture1(1).Visible = True
Picture1(0).Visible = False
Picture1(3).Visible = False
Picture1(2).Visible = False
lblMsg = "Tab #2"
Case 2 'Tab #3
Picture1(2).Visible = True
Picture1(0).Visible = False
Picture1(1).Visible = False
Picture1(3).Visible = False
lblMsg = "Tab #3"
Case 3 'Tab #4
Picture1(3).Visible = True
Picture1(0).Visible = False
Picture1(1).Visible = False
Picture1(2).Visible = False
lblMsg = "Tab #4"
End Select
Set lblMsg.Container = Picture1(intSelTab)
Set cmdExit.Container = Picture1(intSelTab)
End Sub

'For this project you will need:

'1 Form -frmExample

'1 Command button - cmdExit

'1 TabStrip -tbsExample, you should place this first or make sure

' you move to back

'1 Label -lblMsg

'Place 4 tabs onto the tabstrip

'4 Pictureboxes (in an array)

'A) Picture1(0)

'B) Picture1(1)

'C) Picture1(2)

'D) Picture1(3)












( tabstripsample.html )- by Paolo Puglisi - Modifica del 17/12/2023