SEARCH
0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Prev | Current Page 174 | Next

Jim DeMarco

"Pro Excel 2007 VBA"

Then we move into an inner loop to
walk through the columns on the configuration worksheet, and assign them to the corresponding
property in the internal cStep object. The m_iNumSettings value will have already been set
via the NumberOfSettings property before this code is run.
Finally, we add the cStep object to our internal collection, colReturn, passing in the Order
value as the key in the collection.
CHAPTER 4 n USERFORMS 176
nNote It is important to note the first line of code inside the outer loop, Set m_oStep = New cStep. If
this is omitted, you will end up with four identical cStep objects in your collection (all containing the data
from the last configuration item read from the worksheet). This is because the m_oStep object reference is
still active, so every call to it modifies any existing instances. By using the New keyword, you create a new,
separate instance of the object.
The last thing we??™re doing is setting the internal m_iNumSteps variable that is used to track
our Previous and Next CommandButton availability, and finally we??™re returning the collection:
m_iNumSteps = colReturn.Count
Set PageSettings = colReturn
Now we will turn our attention to our PreviousButton and NextButton properties. You??™ll
recall that our internal variables for these properties were declared WithEvents. When you
declare an object WithEvents, you have access to that object??™s event code via the VB code window??™s
Object box, as shown in Figure 4-27.
Figure 4-27.


Pages:
162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186