The Option-Graph Project

Basic Option Graph Step 3

Copy the Leg1 Panel to Three New Option Legs

First, we are going to allow an option price of "0.00" to be displayed, as well as calculating and graphing very low and high priced stocks. Change the following Control Properties on the Leg1 Panel:


Next, we will take advantage of a Visual Basic feature that lets you treat a Panel and all the Controls on it as a single object. This will allow us to copy the Leg1 Panel, and Paste it 3 times to make Panels and Controls for Legs 2, 3, and 4.

Click on the background of lowest Panel, the one that has the "Find Price" and "Find IV" buttons on it. Then click on the four-way arrow symbol in the upper left corner of that Panel, and use your mouse to move the Panel down a couple inches.

Now click the background of the Leg1 Panel, and press CTRL-C to copy it. Click on the gray background of Form1, then press CTRL-V to paste a copy of the Panel. Use your mouse as before to position the new Panel under the Leg1 Panel.

Click on the Form1 background again, press CTRL-V again to paste another copy, and move the new Panel under the other two.

Do the same thing one more time, so you have four Leg Panels and all their Controls.

Now comes the tedious part. When you copy Controls, Visual Basic cannot use the same name as the old Control, and it also cannot know what name you want to give the new Control. This means we need to change the Name Property of every new Control to match the Names we will be using in code.

The easiest, fastest, and most error-free way to do this is to click on the Control for Leg1. Then in the Property Window, copy the Name Property by selecting the name and pressing CTRL-C. Now on each of the three other legs, select the same Control on the form, select the Name Property (which will be a generic name like "ComboBox1", and press CTRL-V to paste the Name. Before you leave the Name Property, change the number in the Name to the number of the Leg you are working on. For instance, you will paste "Leg1Type" into the Name Property of the Type Control for Leg2, and change the "1" to a "2" so it says "Leg2Type". Each Leg Control should have all the numbers changed to match the leg you are working on.

If you forget to change the number in the Name before leaving the Name Property, Visual Basic will give an error message, because two Controls cannot have the same Name.

After you change a Name, the best way to leave the field is by pressing your Tab key. If you use your Enter key or click on the Form with your mouse, Visual Basic will give you an annoying "ding".

Each Leg has 13 Controls on it, and you added 3 new legs, so you have 39 Name Properties to change. Don't forget the two small buttons next to each expiration date - they have Names we need to reference in code also.

If you have any question about what a Name is supposed to be, you can skip ahead to the Test the Names page and they are all spelled out there in the testing code.

In addition to the 13 Controls, there is also the Orange Label that says "Leg1". Select each of those and change the Text Property to Leg2, Leg3, and Leg4. Your Form should now look like the picture below:

Save your Project.


Home Page Downloads
Previous Step: Add new Controls to Leg1
Next Step: Add a Stock Leg Panel and Stock Class

Copyright 2017 Privacy Policy

Questions, corrections, suggestions, comments to: this contact

Want to learn options, find strategies? Visit