330 likes | 346 Views
Microsoft Visual Basic 2005 BASICS. Lesson 2 Forms, Controls, and Properties. Objectives. Create a new Visual Studio 2005 project. Save a Visual Studio 2005 project. View and modify form properties. Create controls, such as command buttons. Objectives (cont.).
E N D
Microsoft Visual Basic 2005 BASICS Lesson 2 Forms, Controls, and Properties
Objectives • Create a new Visual Studio 2005 project. • Save a Visual Studio 2005 project. • View and modify form properties. • Create controls, such as command buttons. Microsoft Visual Basic 2005 BASICS
Objectives (cont.) • Move, resize, and delete objects. • Explain the concept of focus. • Set additional properties (BackColor, Top, and Left). Microsoft Visual Basic 2005 BASICS
Creating a New Project • Create a new project • Select the New Project option • From the File menu • Or push the New Project button • On the Start Page Microsoft Visual Basic 2005 BASICS
Creating a New Project (cont.) Microsoft Visual Basic 2005 BASICS
Creating a New Project (cont.) Microsoft Visual Basic 2005 BASICS
Forms • Forms are the windows and dialog boxes when the program runs. • Every program must have at least one form. • All other objects must be contained within forms. Microsoft Visual Basic 2005 BASICS
Forms (cont.) Microsoft Visual Basic 2005 BASICS
Forms (cont.) Microsoft Visual Basic 2005 BASICS
Saving the Project • Visual Basic will save your project whenever you compile the program. • Use the Save All button • To save your project manually Microsoft Visual Basic 2005 BASICS
Viewing and Modifying Properties • The Properties window • Allows you to easily alter the properties of objects • Important properties of a form • The Text property specifies the text that appears in the title bar. • The Name property names the object for coding. Microsoft Visual Basic 2005 BASICS
Viewing and Modifying Properties (cont.) Microsoft Visual Basic 2005 BASICS
Viewing and Modifying Properties (cont.) • Naming objects • Use names that are meaningful and that describe the object you are naming. Microsoft Visual Basic 2005 BASICS
Viewing and Modifying Properties (cont.) Microsoft Visual Basic 2005 BASICS
Creating Controls • Controls are the objects that make up the user interface. • One of the most common controls is the command button. • To create controls, you must access the Toolbox. Microsoft Visual Basic 2005 BASICS
Creating Controls (cont.) Microsoft Visual Basic 2005 BASICS
Creating Controls (cont.) Microsoft Visual Basic 2005 BASICS
Setting Properties of the Command Buttons • Command buttons • Have many properties that can be set • Text property • Specifies the text that the user sees on the command button • Name property Microsoft Visual Basic 2005 BASICS
Moving, Resizing, and Deleting Objects • Objects can be moved and resized. • Using techniques common to most Windows programs • Delete an object • Select the object and press the Delete key. • Snap lines • Colored lines • Help you line objects up with one another Microsoft Visual Basic 2005 BASICS
Moving, Resizing, and Deleting Objects (cont.) Microsoft Visual Basic 2005 BASICS
Moving, Resizing, and Deleting Objects (cont.) Microsoft Visual Basic 2005 BASICS
Understanding Focus • The object that is currently active on the screen is said to have the focus. • Press the Tab key • To move the focus from one control to another • Each object in a window will get the focus in a sequence. • Called the tab order Microsoft Visual Basic 2005 BASICS
Setting Additional Properties • Other properties commonly set when creating Visual Basic programs • BackColor • Position and size of objects Microsoft Visual Basic 2005 BASICS
Setting the BackColor Property • By default, forms have a gray background. • Use BackColor property • To change form background color • Collections of colors • System colors • Web colors • Custom colors Microsoft Visual Basic 2005 BASICS
Setting the BackColor Property (cont.) Microsoft Visual Basic 2005 BASICS
Setting the Top and Left Properties • Use Location property • For precise placements of objects • Location property • Point with X and Y values • Locates the object at a distance from the upper-left corner of a form • By default, the unit of measure is pixels. • Smallest dot on a screen that the computer can address Microsoft Visual Basic 2005 BASICS
Summary • To create your own Visual Basic program, you must create a new project. The Windows Application project template allows you to create a program from scratch. • Projects created using the Windows Application template begin with one blank form. Forms become the windows and dialog boxes when the program runs. Microsoft Visual Basic 2005 BASICS
Summary (cont.) • Every program has at least one form. All other objects must be contained within forms. • Visual Studio 2005 will save your project whenever you compile the program. Microsoft Visual Basic 2005 BASICS
Summary (cont.) • A window created from a Visual Basic form has certain functionality by default, such as the ability to be moved, resized, maximized, minimized, and closed. • Properties are the characteristics of Visual Basic objects. Properties can be modified in the Properties window. Microsoft Visual Basic 2005 BASICS
Summary (cont.) • The Text and (Name) properties are two of the most important properties. The Text property controls what the user sees in the title bar of a form and in other objects, such as command buttons. Microsoft Visual Basic 2005 BASICS
Summary (cont.) • When we add programming code later, the (Name) property allows us to refer to the object using a meaningful name. Programmers often use a naming standard when naming objects. • Controls are the command buttons, text boxes, scroll bars, and other objects that make up the user interface. Microsoft Visual Basic 2005 BASICS
Summary (cont.) • A command button is a standard push-button control that commonly appears in dialog boxes. Command buttons can be moved, resized, and deleted like other Windows objects. • Focus refers to the active status of one of the objects in a window. Only one object can have the focus. Microsoft Visual Basic 2005 BASICS
Summary (cont.) • The BackColor property controls the background color of a form. • The Location property can be used to accurately position objects. By default, the X and Y point values of the Location property use a measurement called pixels. Microsoft Visual Basic 2005 BASICS