0% found this document useful (0 votes)
166 views15 pages

Visual Basics::: Bhumika Shah.. Computer Engineering Department

The document discusses various concepts in Visual Basic including controls, objects, properties, events, methods, and variables. It specifically describes controls like labels and text boxes used to build the user interface. Labels are used to display uneditable text while text boxes allow for user input and output. Properties configure the appearance and functionality of these objects. Events and methods perform actions in response to user interactions.

Uploaded by

bhumika_shah7
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
166 views15 pages

Visual Basics::: Bhumika Shah.. Computer Engineering Department

The document discusses various concepts in Visual Basic including controls, objects, properties, events, methods, and variables. It specifically describes controls like labels and text boxes used to build the user interface. Labels are used to display uneditable text while text boxes allow for user input and output. Properties configure the appearance and functionality of these objects. Events and methods perform actions in response to user interactions.

Uploaded by

bhumika_shah7
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 15

Visual Basics ::

Bhumika Shah..
Computer Engineering Department
Revising concepts…
 Control
 A control is a tool you use to create objects on a
Visual Basic form.
 You select controls from the toolbox and use the
mouse to draw objects on a form.
 You use most controls to create user interface
elements, such as command buttons, image
boxes, and list boxes…
Object

An object is a type of user interface element you


create on a Visual Basic form by using a toolbox
control. (In fact, in Visual Basic, the form itself is
also an object.)
 You can move, resize, and customize objects by
setting object properties.
 Objects also have what is known as inherent
functionality — they know how to operate and can
respond to certain situations on their own. (A list
box “knows” how to scroll, for example.)
Property

 A property is a value or characteristic held by a Visual Basic


object, such as Caption or ForeColor.
 Properties can be set at design time by using the Properties
window or at run time by using statements in the program
code. In code, the format for setting a property is:

 Object. Property = Value


Where
Object is the name of the object you’re customizing.
Property is the characteristic you want to change.
Value is the new property setting.
 For example,
Command1.Caption = "Hello“
= Could be used in the program code to set the Caption
property of the Command1 object to “Hello”.
Event Procedure
 An event procedure is a block of code that runs
when a program object is manipulated.
 For example, clicking the first command button in
a program executes the Command1_Click event
procedure.
 Event procedures typically evaluate and set
properties and use other program statements to
perform the work of the program.
Program Statement
 A program statement is a combination of
keywords, identifiers, and arguments in the code
that does the work of the program.
 Visual Basic program statements create storage
space for data,open files, perform calculations, and
do several other important tasks.
Method
 A method is a special keyword that performs an action or a service
for a particular program object.

In code, the format for using a method is


Object. Method Value
Where
Object is the name of the object you are working with.
Method is the action you want the object to perform.
value is an optional argument to be used by the method.

For example, this statement uses the Add Item method to put the
word Check in the List1 list box:
List1.AddItem "Check"
Variable
 A variable or identifier is a special container
that holds data temporarily in a program.
 Variables can store numbers, names, property

values, and references to objects.


Basic controls revisited ….
 Label ::

 Label, the simplest control in the Visual Basic toolbox, displays


formatted text on a user interface form.

 A label is a control you use to display text that a user can't edit
directly.

 Typical uses for the Label control include:


 Help text
 Program screen headings
 Formatted output, such as names, times, and dates
 Descriptive labels for other objects, including text boxes and list
boxes
 Label Properties ::

Alignment :: Aligns caption within border.


Appearance :: Selects 3-D or flat appearance
AutoSize :: If True, the label is resized to fit the text specifed by
the caption property. If False, the label will remain the size defined
at design time and the text may be clipped.
BorderStyle :: Determines type of border.
Caption :: String to be displayed in box.
Font :: Sets font type, style, size.

 Label Events:
Click Event :: triggered when user clicks on a label.
DblClick Event :: triggered when user double-clicks on a label.
 Creating Labels on a Form
 set label properties ::
You can also set label properties with program code,
as shown in the following.
The program codes below, when command1 button
is clicked, will set the caption of label1 as “Welcome”
and label2 as “Please enter your name below:” ……
Private Sub Command1_Click ()
Label1.Caption = "Welcome"
Label2.Caption = "Please enter your name below:“
End Sub
Textbox
 A Textbox is used to display information
entered at design time, by a user at run-time,
or assigned within code. The displayed text
may be edited.
 This control performs two functions:

1) Displaying output (such as operating


instructions or the contents of a file) on a
form.
2) Receiving text (such as names and phone
numbers) as user input .
Text Box Properties:

1) Appearance :: Selects 3-D or flat appearance.


2) BorderStyle:: Determines type of border.
3) Font Sets :: font type, style, size.
4) MaxLength :: Limits the length of displayed text (0
value indicates unlimited length).
5) MultiLine :: Specifies whether text box displays
single line or multiple lines.
6) PasswordChar :: Hides text with a single character.
7) ScrollBars:: Specifies type of displayed scroll bar(s).
8) Text :: Displayed text.
Text Box Events:
 Change :: Triggered every time the Text property
changes.
 LostFocus :: Triggered when the user leaves the
text box. This is a good place to examine the
contents of a text box after editing.
 KeyPress :: Triggered whenever a key is pressed.

 Text Box Methods:


 SetFocus :: Places the cursor in a specified text
box.
 Good Day!

You might also like