100 likes | 288 Views
Forms. Parts of a form Form: Program User Interface Controls are contained inside forms Control event handlers are contained inside forms. Close button. Control Box. Maximize button. Minimize button. Caption. Design grid. Controls & Properties.
E N D
Forms • Parts of a form • Form: Program User Interface • Controls are contained inside forms • Control event handlers are contained inside forms Close button Control Box Maximize button Minimize button Caption Design grid
Controls & Properties • Control: is an object designed to perform a specific task • Properties: are used to easily customize an object appearance • Properties of a form are saved in “.FRM” files • Form graphics and other binary elements are saved in “.FRX” files • Common properties: • Name • Index • Left • Top • Height • Width • Enabled • Visible
Controls & Properties • Object Position • Left: Horizontal distance from the left of the form • Top: Vertical distance from the top of the form • Changing properties can be at Design time and/or at Run time • Design time: through properties window • Run time: through programming
Measurements & Auto List • Measurements in VB: • Twips: device – independent unit measure = 1/20 of a printer point • 1440 Twips = 1 inch • Auto List: When an object name is typed followed by a dot, VB lists all properties and events (select one using (Ctrl+Enter)
Referencing Controls & Forms • Name property: is a unique identifier by which an object can be referenced in program code. • VB Object type & Common Name Prefix: • CheckBox: chk • ComboBox: cbo • Command Button: cmd • Form: frm • ListBox: lst • Menu: mnu • For a complete list, See page 49
Methods • Methods are: • tasks that controls can perform • Program functions built into bojects • E.g. “.PrintForm” • Common Methods: • Drag • Move • SetFocus • Zorder
Events • Events are triggers that are raised by user, e.g. Click on a command button • To respond to an event a code is written (Event procedure) • Some property changes can trigger events (e.g. changing height or Width property of a form triggers the Resize event)
Displaying a Form • Single form (by default it is the StartUp form) • Select StartUp form from the project menu • Loading a form: • Load frmApplication (loading a form into memory) • Show frmApplication (Loading/Displaying a form) • Modal option: control is only for that form until closed • frmApplication.Show vbModal • Modeless option: control can be given to any part of the program
Unloading a Form • Hiding a form: • frmApplication.Hide (Not removed from the memory) • Unload frmApplication (removes it from the memory) • Unload Me (Me refers to the current object)
If...Then...Else Statement • If condition Then statements [Else elsestatements ] Or, you can use the block form syntax: • If condition Then [statements][ElseIf condition-n Then [elseifstatements]] . . .[Else [elsestatements]]End If