Making Your First Active X Control in Visual Basic - Steps 5-8
(Page 3 of 4 )
Step Five: Get the elements in place
On the left there is a list of possible items that you can use to make your control. In this case we are going to use two of the standard elements to make our spinner box. First select a text box from the options. Draw a small text box onto your workspace. Small is a critical aspect here; your text box only needs to be big enough to hold a number, so keep your sense of scale here.
Next, find the vertical scroll bar next to the text box. Remember, when we are finished with this, it will be one element, so these items need to be touching in order for the end product to look right.
Step Six: Merge the Controls
Use the control sizing handle to draw a box around both the text box and the vertical scroll box. This will allow us to make rules that will apply to both of the items, so be sure that the box encompasses both of the elements that we just added.
Step Seven: Display the code window
The code window will allow us to write the event driven code that will give the scroll bar its functionality. To do this all you have to do is double click on the vertical scroll bar. The code window will open automatically.
Step Eight: Add the code
In order to make the box functions work we need to add this line of code:
"text1.text=vscroll1.value"
This line of code makes the assumption that you kept the default names of the objects that you added to the program. If you made changes to names, then these lines of code will be slightly different. For example, if you re-named the text box texty1 then your text would read like this:
"texty1.text=scrolly1.value"
Next: Steps 9-11 >>
More BrainDump Articles
More By Katie Gatto