Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter
 
 
MSDN Visual Basic Community
 
 
 
 
 
 
TitleMake a Wizard using tabs
Keywordswizard, tabs, steps
CategoriesSoftware Engineering
 
Keep the steps in frames. Use the tabs to hide and display the frames.

This method is appropriate when it makes sense for the user to jump around and skip steps.

 
Private LastStep As Integer
Private CurrentStep As Integer
Private StepFinished() As Boolean

Private Sub Form_Load()
Dim i As Integer
Dim l As Single
Dim t As Single
Dim w As Single
Dim h As Single

    ' Prepare and position the frame controls.
    LastStep = frStep.UBound
    l = tabSteps.Left + 30
    t = tabSteps.Top + 330
    w = tabSteps.Width - 60
    h = tabSteps.Height - 360
    For i = 0 To LastStep
        frStep(i).BorderStyle = vbBSNone
        frStep(i).Move l, t, w, h
    Next i

    ' Hide all but the first step's frame.
    For i = 1 To LastStep
        frStep(i).Visible = False
    Next i

    ' Prepare the tab control.
    tabSteps.Tabs.Clear
    For i = 0 To LastStep
        tabSteps.Tabs.Add , , "Step &" & Format$(i + 1)
    Next i

    ' Make the array of step finished flags.
    ReDim StepFinished(0 To LastStep)
    StepFinished(0) = True

    ' Disable the Finish button.
    EnableButtons
End Sub

Private Sub EnableButtons()
Dim i As Integer
Dim all_finished As Boolean

    all_finished = True
    For i = 0 To LastStep
        If Not StepFinished(i) Then _
            all_finished = False
    Next i

    cmdFinish.Enabled = all_finished
End Sub

Private Sub tabSteps_Click()
    frStep(CurrentStep).Visible = False
    CurrentStep = tabSteps.SelectedItem.Index - 1
    frStep(CurrentStep).Visible = True

    StepFinished(CurrentStep) = True

    EnableButtons
End Sub

Private Sub cmdCancel_Click()
    Unload Me
End Sub

Private Sub cmdFinish_Click()
    MsgBox "Do something with the values entered."
    Unload Me
End Sub
 
 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated