Hi all,
I have an alternate way to make a Wizard-like interface. I'd like to post it as a FAQ, but perhaps someone would be willing to give me some feedback first? Here is the FAQ:
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))
[green]
Private Sub Form_Load()
SSTab1.TabHeight = 1
SSTab1.TabMaxWidth = 15
SSTab1.Width = Me.Width + 200
SSTab1.Left = -100
SSTab1.Tab = 0
End Sub
[/green]
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:
[green]
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
[/green]
And, of course, we need the prepare_tab function:
[green]
Private Function prepare_tab(tab_no As Integer) As Boolean
Dim i As Integer
Select Case tab_no
Case 1
i = 3
'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
[/green]
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:
[green]
Private Sub cmdBack_Click(Index As Integer)
SSTab1.Tab = Index
End Sub
[/green]
And viola! A wizard that is easy to navigate in the design environment and looks good at run time.
I have an alternate way to make a Wizard-like interface. I'd like to post it as a FAQ, but perhaps someone would be willing to give me some feedback first? Here is the FAQ:
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))
[green]
Private Sub Form_Load()
SSTab1.TabHeight = 1
SSTab1.TabMaxWidth = 15
SSTab1.Width = Me.Width + 200
SSTab1.Left = -100
SSTab1.Tab = 0
End Sub
[/green]
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:
[green]
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
[/green]
And, of course, we need the prepare_tab function:
[green]
Private Function prepare_tab(tab_no As Integer) As Boolean
Dim i As Integer
Select Case tab_no
Case 1
i = 3
'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
[/green]
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:
[green]
Private Sub cmdBack_Click(Index As Integer)
SSTab1.Tab = Index
End Sub
[/green]
And viola! A wizard that is easy to navigate in the design environment and looks good at run time.