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 Prev/Next buttons
Keywordswizard, previous, next, steps
CategoriesSoftware Engineering
 
Keep the steps in frames. Use the buttons to hide and display the frames as the user moves through them.
 
Private LastStep As Integer
Private CurrentStep As Integer

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 = frStep(0).Left
    t = frStep(0).Top
    w = frStep(0).Width
    h = frStep(0).Height
    For i = 0 To LastStep
        frStep(i).BorderStyle = vbBSNone
        frStep(i).Move l, t, w, h
    Next i

    ' Initialize the lblStepNumber captions.
    For i = 0 To LastStep
        lblStepNumber(i).Caption = "Step " & _
            Format$(i + 1) & "/" & Format$(LastStep + 1)
    Next i

    ' Hide all but the first step's frame.
    For i = 1 To LastStep
        frStep(i).Visible = False
    Next i
    
    ' Initially enable the buttons.
    EnableButtons
End Sub

Private Sub EnableButtons()
    cmdPrev.Enabled = (CurrentStep > 0)
    cmdNext.Enabled = (CurrentStep < LastStep)

    cmdFinish.Enabled = (CurrentStep = LastStep)
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

Private Sub cmdNext_Click()
    frStep(CurrentStep).Visible = False
    CurrentStep = CurrentStep + 1
    frStep(CurrentStep).Visible = True
    EnableButtons
End Sub

Private Sub cmdPrev_Click()
    frStep(CurrentStep).Visible = False
    CurrentStep = CurrentStep - 1
    frStep(CurrentStep).Visible = True
    EnableButtons
End Sub
 
 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated