Visual Basic 6.0 – Tutorial 1

A picture of Mustang Sally, my dog and friend.

Learning How to Select Controls and Place Them in a Project Using All of the Available Standard Controls

7-22-04

I am assuming that you have already installed Visual Basic 6.0 and have the IDE (Integrated Development Environment) started and have selected a standard EXE for the project.

Screen shot of the Visual Basic 6.0 IDE with a form.

 

The first thing that I always like to do is save the project with the name that I choose. For this project, I will call it ‘AllControls’ and I will name the project and the form the same name, so that I can put the 2 objects together as I look in my directory tree with Explorer. The way that VB saves projects is to save the project file as a *.vbp extension and in this file there are references to all of the different objects used in the project such as forms, controls and modules. If I have many different forms in the same project, I will name them appropriate as to their function such as ‘GraphicsViewer’ or ‘Settings’. So let’s save the project with the name that we choose.

Screen shot of the Visual Basic 6.0 IDE with file menu dropped down.Click on Save Project.

 

Screen shot of the Visual Basic 6.0 IDE with file menu dropped down.Save the form. Change the name in the prompt to ‘AllControls” and the press the enter key. The next screen wants to save the project.

 

Screen shot of the Visual Basic 6.0 IDE with file menu dropped down.

Change the name again to ‘AllControls’ and press the enter key. This the *.vbp file, or project file. The screen should now look like the one below. Notice the new names on the project window.

 

Screen shot of the Visual Basic 6.0 IDE with file menu dropped down.

OK, now let’s create some controls on the project. Let’s start with a text box control.

Screen shot of the Visual Basic 6.0 IDE with file menu dropped down.

 

It is the one with the letters ‘ab|’ inside it. If you hold the mouse arrow over a control, it will tell you what it’s name is. Select the text box by clicking on it and then move your mouse over to the form. You will notice that your mouse now has a large ‘+’ sign. This allows you to place the upper left hand corner of the text box and then, when you are ready to place the text box, click down on the form and hold the left mouse button down while dragging the cursor until you are satisfied with the size and shape of your text box (or any other control). Most controls are placed like this, but there are a few exceptions, such as the timer control, which is not seen when the program actually runs. Here is where I placed my text box, but don’t worry, you can still move and shape the control after you have placed it.

 

Screen shot of the Visual Basic 6.0 IDE with file menu dropped down.

 

Let’s place all of the controls on the form using the same method just described. If you start running out of room for the controls, you can make the form fit the available area by double-clicking the top blue bar, or by grabbing the lower right corner with your mouse and dragging it out to the size desired.

 

Screen shot of the Visual Basic 6.0 IDE with file menu dropped down.

 

This is how my form looks after placing all of the controls available onto the form. Notice that I placed the shape and the line controls inside of the frame control. If you click on the frame control (not on top of the other controls) and drag it, all of the controls that are inside will move with it. This is the purpose of a frame control; to be used as a container for other controls so that you can move and manipulate them as a group. Let’s give the shape control some color. First, give the shape control the focus by clicking right in between the lines of the rectangle (could be a square in your case).

 

Screen shot of the Visual Basic 6.0 IDE with file menu dropped down.

 

Notice that the shape control now has little squares surrounding it. This shows that it has the focus. Now, notice to the right of the working form area that there is an area that has the title bar that says ‘properties’. In the properties frame, it shows the shape control properties. Use the scroll bar to the right and scroll down to the ‘FillColor’ property. Click on the box to the right of the ‘FillColor’ label and a down arrow appears; click on the down arrow.

 

Screen shot of the Visual Basic 6.0 IDE with file menu dropped down.

 

The color chooser box appears. Click on whatever color you like. I like blue. Now, just below the ‘FillColor’ box, there is another property called ‘FillStyle’. By default it is set to ‘Transparent’. Use the down arrow again and select ‘Solid’.

 

Screen shot of the Visual Basic 6.0 IDE with file menu dropped down.

 

Now my shape box is blue. Yours should be the color that you picked. Now, you can see how to select controls and how to set the properties. Each control has different property values, depending on it’s function.

 

Now, let’s run the program that we created. This program doesn’t do much, but you can see how the different controls look on a form. Press the F5 button on your keyboard and the program will start running.

Screen shot of the Visual Basic 6.0 IDE with file menu dropped down.

 

Double-click the blue bar at the top of your form.

 

Screen shot of the Visual Basic 6.0 IDE with file menu dropped down.

 

This is what my program looks like running full screen after double-clicking the blue bar. To close your program, click on the X in the upper right corner of the screen. You should see the IDE back again.

 

Screen shot of the Visual Basic 6.0 IDE with file menu dropped down.

 

This is the end of the tutorial for ‘Learning How to Select Controls and Place Them in a Project Using All of the Available Standard Controls'.

A logo of Ardent Realty Group.

A picture of a young girl using an abacus.

A picture of a keypad key that says Help!