INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Visual Basic (Microsoft) Versions 5/6 FAQ

Graphical User Interface (GUI)

A better (and easier) way to create an Wizard based application by Motor11
Posted: 10 May 04

Using the SSTab control to make a Wizard in VB:

I like to use the SSTab control to make my Wizard-like projects.  It's extremely easy to do and, in my mind, is easier to understand than VB6's Wizard project.

So, first we start our new project:
Start a new project (standard EXE)

And add the sstab control to the project:
Project -> components
    Browse -> tabctrl32 (system32 directory)

    
Add a tab control to the form (sstab1)

Change no. of tabs to reflect no. of wizard steps

Add the following to the form_load event:
(this hides the tabs in the tab control so that the user must navigate the project with the next button (ie: Wizard style))


Private Sub Form_Load()
    SSTab1.TabHeight = 1
    SSTab1.TabMaxWidth = 15
    SSTab1.Width = Me.Width + 200
    SSTab1.Left = -100
    SSTab1.Tab = 0
End Sub


Add a command button (bottom right of tab)
    Name: cmdNext   Caption: Next
Make a copy of this button on each tab -as a control array
Double click next button and add the following code:


Private Sub cmdNext_Click(Index As Integer)
    Dim tab_prepared As Boolean
    If prepare_tab(Index + 1) Then
        SSTab1.Tab = Index + 1
        Debug.Print "User pressed Next " & Str(Index)
    Else
        Debug.Print "Unable to prepare tab " & Str(Index + 1)
    End If
End Sub

And, of course,  we need the prepare_tab function:

Private Function prepare_tab(tab_no As Integer) As Boolean
    Select Case tab_no
    Case 1
        'code to prepare tab number 1
    Case 2
        'code to prepare tab number 2
    End Select
    prepare_tab = True

    Exit Function
errorhandler:
    Debug.Print "Error preparing tab number " & Str(tab_no)
    prepare_tab = False
End Function


Add a control array of 'back buttons in the same manner but starting on tab number 1 (not zero).
The code for the back button could be:

Private Sub cmdBack_Click(Index As Integer)
        SSTab1.Tab = Index
End Sub


And viola!  A wizard that is easy to navigate in the design environment and looks good at run time.

Back to Visual Basic (Microsoft) Versions 5/6 FAQ Index
Back to Visual Basic (Microsoft) Versions 5/6 Forum

My Archive

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close