Professional Documents
Culture Documents
Microsoft Visual Basic: Reloaded: Chapter Two Creating A User Interface
Microsoft Visual Basic: Reloaded: Chapter Two Creating A User Interface
Reloaded
Chapter Two
Creating a User Interface
2
Overview
Object Example
Object Example
Properties
■ Balloon.Color = Red
■ Balloon.Diameter = 10
■ Balloon.Inflated = True
Methods
■ Balloon.Inflate
■ Balloon.Deflate
■ Balloon.Rise(5)
Object Example
Event
Sub Balloon_Puncture()
Balloon.MakeNoise("Bang") Balloon.Deflate
Balloon.Inflated = False
End Sub
■ Buttons
■ Text Box
■ Labels
■ Radio Buttons
■ Check Box
■ Combo Box
■ List Box
■ Tool Tip
■ Numeric Up Down
■ BackColor
■ Enabled
■ ForeColor
■ Location
■ Name
■ Size (Height, Width)
■ Text
■ Visible
Can “manually” set these for now, but we’ll see how
to manipulate the properties with code soon.
2009 Pearson Education, Inc. All rights reserved.
10
■ Button: Click
■ Text Box: TextChanged
■ Radio Button: CheckedChanged
■ Check Box: CheckedChanged
■ Combo Box: SelectedIndexChanged
End Sub
■ Enter
■ TextChanged
■ KeyDown
■ MouseEnter
■ MouseLeave
■ MouseHover
Namespaces
Name of object
(Welcome) Namespace
(System.Windows.Forms)
Welcome Class type of object
application GUI (Form)
objects
Figure 3.43 | Component object box expanded to show Figure 3.44 | The name and class of an object are
the Welcome application’s objects. displayed in the component object box .
Namespace Examples
My Namespace
My.Computer.Audio.Play("c:\windows\media\
Windows XP Startup.wav")
Encapsulation
Labels
Descriptive Label
■ Snap Lines
■ Format Menu Options
■ Lock Controls
■ Align
■ Sizing
■ Spacing
■ Centering
■ Manually Resize Labels
■ Change the Form file name (Form1.vb) to a
name that describes the application’s purpose.
2009 Pearson Education, Inc. All rights reserved.
34
■ AcceptButton property
A form property that designates the name of the default button
Only one per form
Should be the button that is most often selected by the user
(unless the tasks performed by this button are both
destructive and irreversible)