The Object box lists objects declared WithEvents.
Select m_oNextButton and m_oPreviousButton from the Object box to insert their eventhandler
stubs into the class module. Add the following code to each:
Private Sub m_oNextButton_Click()
m_oNextButton.Enabled = Me.NextPage <> m_iNumSteps + 1
m_oPreviousButton.Enabled = Me.PreviousPage <> 0
End Sub
Private Sub m_oPreviousButton_Click()
m_oPreviousButton.Enabled = Me.PreviousPage <> 0
m_oNextButton.Enabled = Me.NextPage <> m_iNumSteps + 1
End Sub
This code controls whether each button is enabled based on the value of the NextPage or
PreviousPage properties of our cStepManager class. We??™ll add one more method to initialize the
buttons when the class is first created in client code:
Public Sub HandleControls()
m_oPreviousButton.Enabled = Me.PreviousPage <> 0
m_oNextButton.Enabled = Me.NextPage <> m_iNumSteps + 1
End Sub
CHAPTER 4 n USERFORMS 177
We??™ve created a fair amount of code here, all stored in objects across many class modules.
By compartmentalizing our functionality, we??™ve made our job of maintaining this code very
easy. If we need to bind lists to data sources we may not be currently handling, it is trivial to
add a new method to the cListManger class. If we need to add a screen to our process, we
design a new page on the MultiPage control, create a new class to store that screen??™s information,
and add a row to our configuration table.
Your Class Modules folder in the Project Explorer should look like Figure 4-28 after all the
classes have been added and coded.
Pages:
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187