Professional Documents
Culture Documents
Type Description
Standard controls : These controls are contained in
Visual Basic.
Examples include the CommandButton and
TextBoxcontrols. Also called intrinsic controls,
standard controls are always available from the
Toolbox and are the main focus of this chapter.
These controls are covered in the topic of Standard
Controls in this chapter.
CAUTION
---------------------------
You must be careful not to write a lot of code in
the Timer event procedure because this code
will be executed at every pulse and therefore
can easily degrade your application's
performance. Just as important, never execute a
DoEvents statement inside a Timer event
procedure because you might cause the
procedure to be reentered, especially if the
Interval property is set to a small value and
there's a lot of code inside the procedure. Timer
controls are often useful for updating status
information on a regular basis. For example,
you might want to display on a status bar a
short description of the control that currently
has the input focus. You can achieve that by
writing some code in the GotFocus event for all
the controls on the form, but when you have
dozens of controls this will require a lot of code
(and time). Instead, at design time load a short
description for each control in its Tag property,
and then place a Timer control on the form with
an Interval setting of 500. This isn't a time-
critical task, so you can use an even larger
value. Finally add two lines of code to the
control's Timer event:
Private Sub Timer1_Timer()
lblStatusBar.Caption = ActiveControl.Tag
End Sub
Drive List Box
Special Events Details
Change ( )
Scroll ( )
Dir List Box
Special Events Details
Change ( )
Scroll ( )
File List Box
Special Properties Value
Archive
Hidden
MultiSelect
Normal
Pattern
ReadOnly
System
Special Events Details
PathChange ( )
PatternChange ( )
Scroll ( )
the DriveListBox control is a combobox-like
control that's automatically filled with your
drive's letters and volume labels. The
DirListBox is a special list box that displays a
directory tree. The FileListBox control is a
special-purpose ListBox control that displays all
the files in a given directory, These controls
often work together on the same form; when the
user selects a drive in a DriveListBox, the
DirListBox control is updated to show the
directory tree on that drive. When the user
selects a path in the DirListBox control, the
FileListBox control is filled with the list of files
in that directory. These actions don't happen
automatically, however—you must write code to
get the job done.
Line
Special Properties Value
BorderColor the color of the line
BorderStyle
BorderWidth
DrawMode
X1
Y1
X2
Y2
Special Events Details
It poses not events
The Line control is a decorative control whose
only purpose is let you draw one or more
straight lines at design time, instead of
displaying them using a Line graphical method
at run time. This control exposes a few
properties whose meaning should sound
familiar to you by now: BorderColor (the color
of the line), BorderStyle (the same as a form's
DrawStyle property), BorderWidth (the same as
a form's DrawWidth property), and DrawMode.
While the Line control is handy, remember that
using a Line method at run time is usually better
in terms of performance.
Here X1, Y1 are line starting co-ordinates and
X2, Y2 are line termination co-ordinates. Line
control can be used to generate graphic on the
application. But same time graphic function
such as Line ( X1, Y1 ) - ( X2, Y2 ) , Color, BF is
much faster and better to generate line at run
time.
Shape
Special Properties Value
BackStyle = 0 - Transaparent
= 1 - Opaque
BorderColor
BorderStyle = 0 - Transparent
= 1 - Solid
BorderWidth
FillColor
FillStyle
Shape display six basic shapes: Rectangle, Square,
Oval, Circle, Rounded Rectangle, and Rounded
Square
Special Events Details
It poses not events
In a sense, the Shape control is an extension of
the Line control. It
can display six basic shapes: Rectangle,
Square, Oval, Circle,
Rounded Rectangle, and Rounded Square. It
supports all the Line
control's properties and a few more:
BorderStyle (0-Transparent, 1-
Solid), FillColor, and FillStyle (the same as a
form's properties with
the same names).
Message Box
The MsgBox function uses the following syntax:
MsgBox( prompt [, buttons] [, title] [, helpFile,
context] )
The arguments for the MsgBox function are
described in the following table.
Argument Description
prompt Text that contains message to the user.
buttons Determines the number of and type of
message box buttons as well as the type of symbol
that appears on the message box.For more
information about using MsgBox function constants,
search for "MsgBox arguments" in MSDN Help. title
The text that appears in the title bar of the message
box. helpFile A string that identifies the Help file to
use to provide context-sensitive Help for the dialog
box. If helpfile is provided, context must also be
provided. context Numeric expression that identifies
the specific topic in the Help file that appears. If
context is provided, helpfile must also be provided.
Note : Any arguments not enclosed in square
brackets are required. You must supply a value
for these arguments. Arguments that are
enclosed in brackets are optional. If values are
not supplied for these arguments, Visual Basic
will use the default value. The following
instruction shows a simple message box that is
generated by the MsgBox function.
MsgBox "This illustration shows a simple
message box that is generated by the MsgBox
function.", vbOkOnly + vbInformation,
"eBookMark"
Often the MsgBox function is used to get a
simple response from the user.
MsgBox ( ) return values
Constant Value Description
vbOk 1 OK
vbCancel 2 Cancel
vbAbort 3 Abort
vbRetry 4 Retry
vbIngore 5 Ignore
vbYes 6 Yes
vbNo 7 No
Input Box
Input boxes are an easy way for you to ask the
ser for input that can't be answered simply by
clicking a button.
MyValue = InputBox ("This illustration shows
Input box that is generated by the Input Box
function.", "eBookMark", "Default Value")
below is a sintex for input box :
InputBox( prompt[, title] [, default] [, xPos] [,
yPos] [, helpFile,context] )
Note
For user input that requires no more than
clicking a button, use the MsgBox function.
When using the InputBox function, there is little
control over the components of the dialog box.
Only the text in the title bar, the command
prompt displayed to the user, the position of the
dialog box on the screen, and whether or not
the dialog box displays a Help button can be
changed. The MsgBox function provides more
control over the appearance of the dialog box.