You can add an indexed property to a class or ActiveX control. If you want to put the class in a separate project (ActiveX DLL or ActiveX EXE), or if you are building an ActiveX control, you'll need to set a reference so the main program's project can refer to the class/control's project.
Select the ActiveX DLL/EXE/control project. Open the Project menu and select the Properties command. Enter the name of the project in the Project Name field. This example uses the name ScoreArrayProject.
Now select the other project, open the Project menu, and select References. Find the ScoreArrayProject entry and select it. Now the main program can use the classes defined in the ActiveX DLL project.
Once you have done this, you can build the property procedures. The following code shows how the ScoreArray class implements an indexed Score property. Note that the main program must call SizeArray to allocate the array before it can use the Score properties. Note also that this simple example does not bounds checking on the index values.
|