Hide

SftTabs/OCX 6.5 - Tab Control for VB6

Display
Print

Wizard Sample (VB6)

This sample illustrates a simple Wizard style form.

The source code is located at C:\Program Files (x86)\Softelvdm\SftTabs OCX 6.5\Samples\Wizard\Form1.frm or C:\Program Files\Softelvdm\SftTabs OCX 6.5\Samples\Wizard\Form1.frm (on 32-bit Windows versions).

Option Explicit

Private Sub UpdateButtons()
    Dim i As Integer
    With SftTabs1.Direct
        ' Update all buttons based on the current tab / page
        If .Tabs.Current = 0 Then
            BtnPrev.Enabled = False
        Else
            BtnPrev.Enabled = True
        End If
        If .Tabs.Current = .Tabs.Count - 1 Then
            BtnNext.Enabled = False
        Else
            BtnNext.Enabled = True
        End If
        ' Also update the image control for the page
        ' Hide all image controls
        For i = 0 To .Tabs.Count() - 1
            Image1(i).Visible = False
        Next
        ' Show one image control for the current page
        Image1(.Tabs.Current).Visible = True
    End With
End Sub

Private Sub BtnCancel_Click()
    ' The user clicked the Cancel button
    End
End Sub

Private Sub BtnFinish_Click()
    ' The user clicked the Finish button
    End
End Sub

Private Sub BtnNext_Click()
    With SftTabs1
        ' Advance to the next tab
        .Tabs.Current = .Tabs.Current + 1
    End With
End Sub

Private Sub BtnPrev_Click()
    With SftTabs1
        ' Go to the previous tab
        .Tabs.Current = .Tabs.Current - 1
    End With
End Sub

Private Sub Check1_Click()
    With Check1
        ' Based on the check box value, enable/disable the Next button
        If .Value = 0 Then
            BtnNext.Enabled = False
        Else
            BtnNext.Enabled = True
        End If
    End With
End Sub

Private Sub Command1_Click()
    MsgBox ("You have clicked the ""Some Action"" button")
End Sub

Private Sub Form_Load()
    ' The Finish button is called Cancel until we reach the last page
    BtnFinish.Caption = "&Cancel"
    ' Pretend we switched to the first page, so the page
    ' is initialized correctly.  The Switched event is normally
    ' only called if the user clicks on a tab or if the
    ' CurrentTab property is modified.
    Call SftTabs1_Switched
End Sub


Private Sub SftTabs1_Switched()
    ' A new tab page has become active
    With SftTabs1
        Call UpdateButtons
        Select Case .Tabs.Current
        Case 0
            ' disable next button based on controls on this new page
            Call Check1_Click
        Case 1
        Case 2
        Case 3
            ' we have visited the last page. The Finish button is
            ' now called Finish
            BtnFinish.Caption = "&Finish"
        End Select
    End With
End Sub

Private Sub SftTabs1_Switching(nextTab As Integer, Allow As Boolean, Refresh As Boolean)
    ' A new tab page is about to become active
    With SftTabs1
        ' validate if user wants to move forward (next)
        If nextTab > .Tabs.Current Then
            Select Case .Tabs.Current
            Case 0
            Case 1
                If Check2.Value = 0 Then
                    MsgBox ("Before you can continue, please select the checkbox shown.")
                    Allow = False ' prevent tab switching
                End If
            Case 2
            Case 3
            End Select
        End If
    End With
End Sub

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