Business programming chapter 2
Business programming chapter 2
Visual Basic
• Language used to create Windows applications.
• Provides a Graphical User Interface or GUI.
• The instructions executed in the program is controlled by events.
4 Ways to Place a Control from the Toolbox onto the Form Designer
• Double-click
• Drag and Drop
• Click, Point, and Click
• Click, Point, and Drag
Setting Properties
• Click on property name in left column.
• Enter its setting into right column by typing or selecting from options displayed
via a button or ellipsis
Button Control
• The caption on the button should indicate the effect of clicking on the button.
Label Control
• Used to identify the contents of a text box
• Text property specifies caption
• By default, label automatically resizes to accommodate caption on one line.
• When the AutoSize property is set to False, label can be resized manually.
AutoSize is used primarily to obtain a multi-rowed label.
Fonts
• Proportional width fonts, such as Microsoft Sans Serif, use less space for “I” than
for “W”.
• Fixed-width fonts, such as Courier New, take up the same amount of space for
each character.
• Fixed-width fonts are used for tables
Auto Hide
• Hides Toolbox when not in use
• Vertical push pin icon indicates auto hide is disabled.
• Click the push pin to make it horizontal and enable auto hide.
Tab Order
• The tab indices determine the order in which controls receive the focus during
tabbing.
• The control whose TabIndex property is set to 0 has the focus when the program
begins.
Event
• An event is an action, such as the user clicking on a button
• Usually, nothing happens in a Visual Basic program until the user does something
and raises an event.
• What happens is determined by statements inside the event procedure
Focus
• When you click on a text box, a cursor appears in the text box, and you can type
into the text box.
• Such a text box is said to have the focus.
• If you click on another text box, the first text box loses the focus and the second
text box receives the focus
Sample Statements
• txtBox.ForeColor = Color.Red
• txtBox.Visible = True
• txtBox.Text = "Hello World"
Examples of Events
• btnShow.Click
• txtBox.TextChanged
• txtBox.Leave
Sample Form
Double-click on txtFirst to create the outline for the Code Editor
Sample Form
Double-click on btnRed to return to Code Editor and add the outline of an event
procedure.