Username:
Password:
Microsoft Visual Basic 2005 Tutorials

Saving & Executing Projects / Basic Form Properties

Subtitles of the Movie

In this movie I will focus on forms and its associated properties, just like controls, a form has properties that can be set by the programmer at design time. Also just like controls, there is a name property associated with the form. As you can see, the name of the form is Form 1. Now note before I change the name of this form that the word Form 1 appears in the caption or the text property of the form itself in the blue title bar. So as I change the name of this form to for example Sample Form using the word form in the name itself so that it's identifiable and also using Camel Casing, I've not changed the name to Sample Form, but note that the text property still says Form 1, Form 1 is the text property here where the name of the form is Sample Form. To change the text property, simply scroll down to the text property itself and then create an appropriate text. Here, it's perfectly okay to use spacing and this is simply what the user is going to see in the caption portion of the form itself, otherwise known as the text property. Another property you may want to experiment with is the back color property for the form. The back color can be changed by simply going to the back color property, clicking the drop down arrow, going to the custom tab, and choosing the appropriate color. There is another property called the fore color that you may want to experiment with, again, go to the fore color property, click the drop down arrow, choose custom tab, and then you choose the appropriate color. Now, in this case since I do not have any objects on the form you do now see the result of the fore color yet but you will in a moment. Looking up at the text property of the form, demo form, beside it is an icon this is the default icon, this can be changed by going to the icon property, clicking the ellipses button and then simply selecting any other appropriate graphical file that you might have that you might want to change this icon to. If you prefer not to have the icon visible at all, there is a property called Show Icon, which as you can see is set to true by default, if I were to change this to false, as you can see now on the form itself the icon is no longer visible. Remaining in the blue title bar, we have our standard minimize, maximize, and close buttons. The minimize button has a minimize property, minimize box property, and as you can see it is set to true by default. I could change that to false, and as you can see on the form, it is now dimmed or disabled. Likewise, for the maximize box property, it is set to true, I can change that to false as well. Once I do that, they both disappear from the form itself. Note that the close button, the X remans on the form at all times. This is because you want to be able to give the user a way to close the form or to stop the application. But if you wish to remove the options of minimizing or maximizing the forms that's available to you. Not to demonstrate the last two properties, I will draw two buttons on the form and as I do this you will see the effect of the fore color property which you will recall I changed to a blue color earlier. So every object that I now place onto the form is by default going to have blue as their fore color property which is the text in this case. Now as we know, the default name for Button 1 is Button 1 and for Button 2 is Button 2. If I choose to change the name of this button, Button 1, to for example, Enter Button. And change the text to Press Enter and for Button 2 I will change the name to Escape Button and change the text property of this to Press Escape Key, make it a little bit bigger here. Now, the reason I have named and re-captioned these buttons this way is to demonstrate the properties Accept Button and Cancel Button. The Accept Button and Cancel Button are special properties that you associate with the form and as you can see if you go the the Accept Button property right now, there is none, nothing has been associated with the Accept Button property. The Accept Button property automatically links your form with the Enter Key. So if I click on the drop down arrow, I see I have two choices which are the names of the two buttons that I have now created in my form. So if I associate Enter Button with Accept Button and then go down to the Cancel Button property which again by default says none, I can associate the Escape button with the Cancel Button property and what this will do is when the application is executed instead of clicking the Enter Key the user now has the option of actually pressing the Enter Key as opposed to clicking the Enter Button. And likewise for the Escape Button, the user can press the Escape Key on the keyboard and whatever code you have associated with these two buttons will be executed respectively with the Enter key and Escape keys. You will want to take care in associating the correct code with these features since when the user presses the Enter Key, whatever code you have associated with that button will indeed be executed. For example, you might associate a process button or a calculate button with the Enter Key, you might associate the Quit option to shut the program down with the Escape Key for example.

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