Username:
Password:
Microsoft Visual Basic 2005 Tutorials

Introduction / A Simple Example

Subtitles of the Movie

In this movie I will create a simple example simply to demonstrate how controls can be placed on the form and how you can write a very simple line of code to allow the user to interact with your application. For this example, I will need two objects, I will need a button so I will click on Button and drag it onto the form, I also need a label so I click the Label icon from the toolbox, Select, and draw it onto the form. The first thing I want to do is to affect the label and that is I want to change the default border style. If you select Label 1 and move over to the Properties window making sure you are printing on Label 1, find in the properties list a property called Border Style. By default, the border style is none. If I click on the drop down arrow I'll choose fixed 3D. This will give me a little bit of a focus on the label control. Now this is a very simple example so all I need at this point is a line of code to allow the user to interact with the button. The simplest way to write code for a button is to at design time which is what we're in currently, design time, is to double click the button. By double clicking you automatically open the event procedure for the Button 1 click event. That is, when the user clicks Button 1, the code we're about to write will be executed. Since I know the name of the label is Label 1, I will type Label 1.text equals and then in quotation marks I will place a simple phrase such as ÒHello, how are you?Ó Once you are finished you can either return to the form or click on the by clicking the form 1.VB tab, you can return to the code by clicking the form 1 .VB tab, you can toggle back and forth between these two views but you can run the project from any view whether the design view or the code view. To run, the simplest way is to simply click the Start Debugging control on the toolbar. So let's start and the project begins to run. The form is movable on the form and you'll notice that the top of the screen it does say Running so we are in run time at this point in time. When the user clicks on one the phrase that we typed into our code ÒHello, how are you?Ó does indeed appear. Now let's just make one with alteration to this, so I'll close this window by clicking the close button on the form itself, returning me to the design mode and once again I will return to the label and I will change the property, the font property, and I'll make this a little bit bigger so I want to change the font to bold italic size of 12. I will then click OK and you immediately see that Label 1 does indeed look different. Run the project by clicking the Run button, the form appears, I click on Button, and once again the form appears but this time, in a different font. Now what you have to be careful about is that you don't make your font size is too large otherwise your objects may not fit on the form properly. Now this were a real project we would then begin talking about how to save this and obviously make this a little more complex. In a future movie we will discuss saving and modifying an existing project.

Tutorial Information

Course: Microsoft Visual Basic 2005
Author: Arthur Lee
SKU: 33940
ISBN: 1-935320-10-6
Release Date: 2008-11-19
Duration: 7.5 hrs / 97 lessons
Work Files: Yes
Captions: Available on CD and Online University
Compatibility: Vista/XP/2000, OS X, Linux
QuickTime 7, Flash 8

VTC Sign up & Benefits

  • Unlimited Access
  • 81,350 Video Tutorials (20,800 free)
  • Video Available as Flash or QuickTime
  • Over 782 Courses
  • $30 for One Month Access
  • Multi-User Discounts Available