SlideShare a Scribd company logo
1 of 62
Download to read offline
Introduction
to
VP Programming
Prof. K ADISESHA (Ph. D)
Introduction
to
Part-4
Introduction
Builtin Functions
Queries
Tool Box
Form Controls
2
Visual Basic 6
CONTROL PROPERTIES
Prof. K. Adisesha (Ph. D)
Event Controls
VISUAL BASIC FUNCTIONS
Prof. K. Adisesha (Ph. D)
3
Built in Functions:
Built in functions in VB are classified into following types.
➢ Input Box Function
➢ MsgBox Function
VISUAL BASIC FUNCTIONS
Prof. K. Adisesha (Ph. D)
4
MessageBox Function In Visual Basic:
Displays a message in a dialog box and wait for the user to click a button, and returns an
integer indicating which button the user clicked.
➢ Following is an expanded MessageBox-
➢ Syntax :
MsgBox ( Prompt [,icons+buttons ] [,title ] )
variable = MsgBox ( prompt [, icons+ buttons] [,title] )
➢ Prompt : String expressions displayed as the message in the dialog box.
➢ Icons + Buttons : Numeric expression that is the sum of values specifying the number and
type of buttons and icon to display.
➢ Title : String expression displayed in the title bar of the dialog box. If you omit title, the
application name is placed in the title bar.
VISUAL BASIC FUNCTIONS
Prof. K. Adisesha (Ph. D)
5
MessageBox Function In Visual Basic:
➢ Following is an expanded MessageBox-
➢ Syntax :a = MsgBox(“Are you sure", 16 + 4, “Warning")
➢ Buttons
Constant Value Description
vbCritical 16 Display Critical message icon
vbQuestion 32 Display Warning Query icon
vbExclamation 48 Display Warning message icon
vbInformation 64 Display information icon
Constant Value Description
vbOkOnly 0 Display OK button only
vbOkCancel 1 Display OK and Cancel buttons
vbAbortRetryIgnore 2
Display Abort, Retry and Ignore
buttons
vbYesNoCancel 3
Display Yes, No and Cancel
buttons
vbYesNo 4 Display Yes and No buttons
vbRetryCancel 5 Display Retry and Cancel buttons
➢ Icons
VISUAL BASIC FUNCTIONS
Prof. K. Adisesha (Ph. D)
6
InputBox Function In Visual Basic:
Displays a prompt in a dialog box, waits for the user to input text or click a button, and
returns a String containing the contents of the text box.
➢ Syntax :
variable = InputBox (prompt[,title][,default])
ans = InputBox("Enter message”, "Testing", 0)
➢ Prompt : String expression displayed as the message in the dialog box.
➢ Title - String expression displayed in the title bar of the dialog box. If you omit the title, the
application name is displayed in the title bar
➢ default-text - The default text that appears in the input field where users can use it as his
intended input or he may change to the message he wish to key in.
➢ x-position and y-position - the position or the coordinate of the input box.
VISUAL BASIC CONTROLS
Prof. K. Adisesha (Ph. D)
7
Control Property:
VISUAL BASIC CONTROLS
Prof. K. Adisesha (Ph. D)
8
Toolbox Window:
The Tool box contains the icons of the controls you can place on a form to create the
application's User Interface.
➢ By default, the Toolbox contains the pointer icon and the icons of 20 ActiveX controls.
➢ Pointer : The pointer is not a control but can be used with the controls on the form i.e.
resize, move them etc.
➢ Picture Box: This control is used to display images. The images are set with the picture
property of this control.
➢ Label : This control is used to display text that the user cannot edit it. The text is set with
the caption property of this control. Normally this control is used to display names,
initial values at design time and program results at run time through the code.
VISUAL BASIC CONTROLS
Prof. K. Adisesha (Ph. D)
9
Toolbox Window:
The Tool box contains the icons of the controls you can place on a form to create the
application's User Interface.
➢ TextBox : This control displays text that the user can edit. The text is set with the text property of this
control. This control normally used to accept the inputs from the user and also to display program results
to the user.
➢ Frame : This control is used to group the other controls. It used to draw boxes on the form and other
required controls can be placed inside this box area making a group of controls on the form.
➢ CommandButton : A command button represents an action that is carried out when the user clicks the
button. Action is associated with the click event of this control in program code.
➢ CheckBox : This control is used to provide a choice of selection to the user. It shows a check (or right)
mark on one click and clears on another click i.e. it toggles (or changes) on every click.
VISUAL BASIC CONTROLS
Prof. K. Adisesha (Ph. D)
10
Toolbox Window:
The Tool box contains the icons of the controls you can place on a form to create the
application's User Interface.
➢ OptionButtons: This control also called as radio button is used to provide a choice of action to the
➢ user. It shows a small shaded dot like circle when selected and cleared when not selected The value
property is used to on and off like car radio button.
➢ ListBox : This control provides a list of text items from which the user can select one or more. The text
cannot be edited by the user, but on selection, the selected item's text can be used to display.
➢ ComboBox : This control is similar to ListBox control but it contains text edit field. The user can select
an item from the list like ListBox control or enter new text in the edit field.
➢ Horizontal and Vertical ScrollBars : These controls similar to familiar scroll bars found in many
of the applications. These can be used to scroll the contents of controls those do not have built-in vertical
and horizontal scroll bar properties.
VISUAL BASIC CONTROLS
Prof. K. Adisesha (Ph. D)
11
Toolbox Window:
The Tool box contains the icons of the controls you can place on a form to create the
application's User Interface.
➢ Timer: This control facilitates the user to schedule certain events in the program. It has the
facility to set time intervals. The interval property of this control is set to schedule the events.
➢ Shape : This control is used to draw graphical elements, such as rectangles, circles, and squares
on the form.
➢ Line : Similar to the shape control, the line control can be used to draw the straight lines on the
form.
➢ Image : This control can be used to display image. This control is similar to the Picture Box
control but has minimum number of facilities than the Picture Box control.
➢ Data : This control is used to connect databases. This has many properties and methods to
facilitate data access.
VISUAL BASIC CONTROLS
Prof. K. Adisesha (Ph. D)
12
Toolbox Window:
The Tool box contains the icons of the controls you can place on a form to create the
application's User Interface.
➢ OLE: Three controls namely, DrivelistBox, DirectoryListBox. and FileListBox are extending
➢ the users ability to handle file system of the system.
➢ File system related controls : This control can be used to display image. This control is
similar to the Picture Box control but has minimum number of facilities than the Picture Box
control.
❖ DrivelistBox : This control displays the drives on the system in a drop-down list form. The
user can select any drive from the list.
❖ DirectoryListBox : This control displays a list of all folders in the current drive and lets the
user move up or down in the hierarchy of the folders.
❖ FileListBox : This control displays a list of all files in the current folder or directory.
Property Property
Left The position of the left side of a control with respect to its container
Top The position of the top of a control with respect to its container
Height A control's height
Width A control's width
Name The string value used to refer to a control
Enabled The Boolean (True/False) value that determines whether users can manipulate the control
Visible The Boolean (True/False) value that determines whether users can see the control
VISUAL BASIC CONTROLS
Prof. K. Adisesha (Ph. D)
13
Common properties, methods and events of controls:
Every object, such as a form or control, has a set of properties that describe it.
➢ Although this set isn't identical for all objects, some properties.
VISUAL BASIC CONTROLS
Prof. K. Adisesha (Ph. D)
14
Common Events of controls:
Events are what happen in and around your program. For example, when a user clicks a
button, many events occur.
➢ The mouse button is pressed, the CommandButton in your program is clicked, and then the
mouse button is released.
➢ These events occur as a result of some specific user action, such as moving the mouse, pressing a
key on the keyboard, or clicking a text box.
➢ These types of events are user-initiated events and are what you will write code for most often.
➢ Example of Click event for CommandButton
Private Sub Command1_Click()
Print "Click event activated"
End Sub
➢ When the user clicks on the commandbutton1 “Click event activated” will print on the form.
Event Occurrence
Change The user modifies text in a combo box or text box
Click The user clicks the primary mouse button on an object.
DblClick The user double-clicks the primary mouse button on an object.
DragDrop The user drags an object to another location.
DragOver The user drags an object over another control.
KeyPress The user presses and releases a keyboard key while an object has focus.
GotFocus & LostFocus An object receives focus & An object loses focus.
MouseMove The user moves the mouse pointer over an object.
VISUAL BASIC CONTROLS
Prof. K. Adisesha (Ph. D)
15
Common Events of Visual Basic Controls:
➢ Although this set isn't identical for all objects, some Event Controls.
VISUAL BASIC CONTROLS
Prof. K. Adisesha (Ph. D)
16
Methods:
Methods are blocks of code designed into a control that tell the control how to do things,
such as move to another location on a form.
➢ Just as with properties, not all controls have the same methods, although some common methods
do exist. Common Methods of Visual Basic Controls:
Method Use
Move Changes an object's position in response to a code request
Drag Handles the execution of a drag-and-drop operation by the user
SetFocus Gives focus to the object specified in the method call
ZOrder Determines the order in which multiple objects appear onscreen
Event Occurrence
Change The user modifies text in a combo box or text box
Click The user clicks the primary mouse button on an object.
DblClick The user double-clicks the primary mouse button on an object.
DragDrop The user drags an object to another location.
DragOver The user drags an object over another control.
KeyPress The user presses and releases a keyboard key while an object has focus.
GotFocus & LostFocus An object receives focus & An object loses focus.
MouseMove The user moves the mouse pointer over an object.
VISUAL BASIC CONTROLS
Prof. K. Adisesha (Ph. D)
17
Common Events of Visual Basic Event Controls:
➢ Although this set isn't identical for all objects, some Event Controls.
VISUAL BASIC CONTROLS
Prof. K. Adisesha (Ph. D)
18
Form Control Properties:
The controls or objects viewed as user interface elements have set of properties. Visual
Basic assigns default properties to every new control you place on a form.
➢ Few properties are available only at design time and a few properties available only at
run time. Some run time properties are read only.
➢ The properties of the control are accessed with the syntax consisting control's name
followed by a period followed by property as shown
Controlname.property
Form Properties:
Name, Caption, Appearance, BackColor, BorderStyle, Picture, Movable, Height, Width,
Left, Top, Visible :
VISUAL BASIC CONTROLS
Prof. K. Adisesha (Ph. D)
19
The following properties apply to Form objects:
➢ Name : This property sets the name of the control, through which you can access the
control's properties and methods in the program code.
➢ Appearance : It has Two Values
❖ • If it is Set to 1-3D ,it allows to set 3-D Appearance at run time.
❖ • If it is Set to 0-Flat , it allows only 2-D Effects at run time
Example : Form1.Appearance = 1 or Form1.Appearance = 0
➢ Caption : This property sets the text that is displayed on many controls or used to
display text in the title of the control.
Example : Form1.Caption = "form title“
➢ Font : This property sets the face, attribute, and size of the font used for the text on the control.
Example : Form1.Font = "Arial"
Form1.FontSize = 50
VISUAL BASIC CONTROLS
Prof. K. Adisesha (Ph. D)
20
The following properties apply to Form objects:
➢ BorderStyle : The BorderStyle Property determine the style of the form’s border and
appearance of then form.
➢ The BorderStyle Property can take one of the values shown in below table
❖ 0 – none : Form Cant be resized and move at run time.
❖ 1 - Fixed single : Cant be resized but we can move.
❖ 2 – Sizeable : User can resize and move the form.
❖ 3 – Fixed dialog : User cant resize the form.
❖ 4 – Fixed tool window : Similar to fixed dialog.
Example : Form1.BorderStyle = 2
➢ BackColor : This property sets the background color of the control.
Example : Form1.BackColor = vbRed
➢ ForeColor : This property sets the foreground color of the control.
Example : Form1.ForeColor = vbRed
VISUAL BASIC CONTROLS
Prof. K. Adisesha (Ph. D)
21
The following properties apply to Form objects:
➢ Text: This property sets the text that is displayed on the controls that accept user input,
Example : Text1.Text = "TextBox Topic Explanation“
➢ Width, Height : : These properties set the control's dimensions.
❖ Height : To change the height of the control.
❖ Width : The width of control can be change.
Example : Form1.Height = 500
Form1.Width = 500
➢ Left, Top : These properties set the conditions of the control's upper-left corner, expressed in the units
of the container (usually a form).
❖ Left : It determines the distance of the control from the left of the screen.
❖ Top : It determines the distance of the control from the top of the screen.
Example : Form1.Left = 100
Form1.Top = 100
VISUAL BASIC CONTROLS
Prof. K. Adisesha (Ph. D)
22
The following properties apply to Form objects:
➢ Enabled: By default, this property's value is true, which means that the control can get the
focus. If it is set to false the control is disabled. ,
Example : Form1.Enabled = True
Form1.Enabled = False
➢ Picture : This is property sets/restes a graphic in the control. If a bitmap image is
assigned to this property, the image is displayed on the control.
➢ Visible :Set this property to true to make a control visible. Set this property to false to make a control
invisible.
Example : Form1.Visible = True
Form1.Visible = False
VISUAL BASIC CONTROLS
Prof. K. Adisesha (Ph. D)
23
Control's Methods :
The Controls or objects have methods which are the actions carried out by them. These
actions invoked from you with in your code.
➢ The following are the few common methods.
➢ Print : the Print method is used to display the text on the form
Example : Form1.print “print method of form”
➢ Clear : The clear method tells the control to clear its contents On controls
➢ Example :The code that can be used in the program is as
Form1.Clear
ListBox1.Clear
Clipboard.Clear
VISUAL BASIC CONTROLS
Prof. K. Adisesha (Ph. D)
24
The following properties apply to Pointer objects:
➢ MousePointer: returns or sets the type of mouse pointer displayed when mouse is moved over
part of an object.
Example : Form1.MousePointer = 1
➢ Tag : Stores any extra data need for your program.
➢ ToolTipText : Allows the text to be displayed when mouse pointer is brought over the control.
➢ Tab Order: All windows applications allow the user to move the focus from one control to
another
VISUAL BASIC CONTROLS
Prof. K. Adisesha (Ph. D)
25
Control's Methods :
➢ Move: All controls that are visible at run time provide Move method that lets you to move and
resize them with in your code. The syntax of the move method is
ControlName. Move left, top, width, height
Example : Form1.Move 50,50,500,500
➢ Refresh : This method when used forces a complete repaint of object.
The syntax is Refresh( )
The use of this method with controls is control-name. refresh
Example : form1.refresh
➢ Zorder : This method when used places a specified control or object at the front or back of the Z-
order within its graphical level.
The syntax is Zorder([Position])
Example : Form1.ZOrder(0)
if it is zero, the object is placed front, if it is 1 the object is placed back of the control
VISUAL BASIC CONTROLS
Prof. K. Adisesha (Ph. D)
26
Control's Methods :
➢ Set Focus: This method when used moves the focus to the specified object. This method is
present with the controls. where user interaction at run time is possible like TextBox control
where user can enter text in it at run time.
The syntax is Set Focus()
The use of this method with controls is control-name. Set Focus
Example : Form1.SetFocus
Text1.SetFocus
➢ Show : The Show method is used to display the control.
Example : Form1.show
➢ Hide: The Hide Method is opposite of show method that not displayed or hide the control
Example : Form1.Hide
VISUAL BASIC CONTROLS
Prof. K. Adisesha (Ph. D)
27
Label Control Methods :
The label is a very useful control for Visual Basic, as it is not only used to provide instructions
and guides to the users, it can also be used to display outputs.
One of its most important properties is Caption. Using the syntax Label.Caption, it can display text
and numeric data. You can change its caption in the properties window and also at runtime.
➢ Some important Properties of Label Control:
❖ Caption - the text that is displayed in the label
❖ BackColor and ForeColor - colors of the background
and the text
❖ BackStyle - Opaque or Transparent - whether the
background is visible or not
❖ Font - font and size of text
❖ Alignment - text centered, left or right
VISUAL BASIC CONTROLS
Prof. K. Adisesha (Ph. D)
28
Label Control Methods :
VISUAL BASIC CONTROLS
Prof. K. Adisesha (Ph. D)
29
TextBox Control Methods :
The TextBox is like a Label but, it is used to input data into the program. The data typed in is in
the Text property of the control. TextBox controls offer a natural way for users to enter a value in
your program.
Private Sub Command1_Click()
Sum = Val(Text1.Text) +Val(Text2.Text)
Label1.Caption = Sum
End Sub
VISUAL BASIC CONTROLS
Prof. K. Adisesha (Ph. D)
30
TextBox Control Methods :
The following Figure summarizes the common TextBox control's properties and methods.
Property Property Description
Enabled specifies whether user can interact with this control or not
Index Specifies the control array index
Locked If this control is set to True user can use it else if this control is set to false the control cannot be used
MaxLength Specifies the maximum number of characters to be input. Default value is set to 0 that means user can input
any number of characters
MousePointer Using this we can set the shape of the mouse pointer when over a TextBox
Multiline Multiline By setting this property to True user can have more than one line in the TextBox
PasswordChar This is to specify mask character to be displayed in the TextBox
Text Specifies the text to be displayed in the TextBox at runtime
VISUAL BASIC CONTROLS
Prof. K. Adisesha (Ph. D)
31
TextBox Control Methods :
The following Figure summarizes the common TextBox control's properties and methods.
Events Event procedures Description
Change Action happens when the TextBox changes
Click Action happens when the TextBox is clicked
GotFocus Action happens when the TextBox receives the active focus
LostFocus Action happens when the TextBox loses it focus KeyDown Called when a key is
pressed while the TextBox has the focus
KeyUp Called when a key is released while the TextBox has the focus
Methods
SetFocus Transfers focus to the TextBox
VISUAL BASIC CONTROLS
Prof. K. Adisesha (Ph. D)
32
FRAME CONTROL :
Frame controls are similar to Label controls in that they can serve as captions for those controls
that don't have their own. Moreover, Frame controls can also behave as containers and host
other controls.
➢ Controls that are contained in the Frame control are said to be child controls. Moving a control
at design time over a Frame control—or over any other container.
➢ Frame controls, like all container controls, have two interesting features.
❖ If you move a Frame control, all the child controls go with it.
❖ If you make a container control disabled or invisible, all its child controls also become disabled
or invisible.
VISUAL BASIC CONTROLS
Prof. K. Adisesha (Ph. D)
33
FRAME CONTROL :
Frame controls are similar to Label controls in that they can serve as captions for those controls
that don't have their own.
Frame
Properties Methods Events
Appearance, BackColor, Caption, ClipControls,
Container, DragIcon, DragMode, Enabled,
Font, FontBold, FontItalic, FontName, FontSize,
FontStrikethru, FontUnderline, ForeColor,
Height, HelpContextID, hWnd, Index, Left,
MouseIcon, MousePointer, Name, Parent,
TabIndex, Tag, Top, Visible, WhatsThisHelpID,
Width
Drag, Move,
Refresh,
ShowWhatsThis,
ZOrder
Click, DblClick,
DragDrop, DragOver,
MouseDown,
MouseMove, MouseUp
VISUAL BASIC CONTROLS
Prof. K. Adisesha (Ph. D)
34
COMMAND BUTTON CONTROL :
The command button is one of the most important controls as it is used to execute commands. It
displays an illusion that the button is pressed when the user click on it.
➢ The most common event associated with the command button is the Click event, and the syntax
for the procedure is.
➢ The Caption property determines the text to display on the face of the button.
Private Sub Command1_Click()
Dim yourpassword As String
yourpassword = Text1.Text
MsgBox ("Your password is: " & yourpassword)
End Sub
VISUAL BASIC CONTROLS
Prof. K. Adisesha (Ph. D)
35
COMMAND BUTTON CONTROL :
The most common event associated with the command button is the Click event.
Command
Button
Properties Methods Events
Appearance, BackColor, Cancel, Caption,
Container, Default, DragIcon, DragMode,
Enabled, Font, FontBold, FontItalic,
FontName, FontSize, FontStrikethru,
FontUnderline, Height, HelpContextID, hWnd,
Index, Left, MouseIcon, MousePointer, Name,
Parent, Style, TabIndex, TabStop, Tag, Top,
Value, Visible, WhatsThisHelpID, Width
Drag, Move,
Refresh,
ShowWhatsThis,
ZOrder
Click, DragDrop,
DragOver, GotFocus,
KeyDown, KeyPress,
KeyUp, LostFocus,
MouseDown,
MouseMove, MouseUp
VISUAL BASIC CONTROLS
Prof. K. Adisesha (Ph. D)
36
CHECKBOX CONTROL :
The Check Box control lets the user selects or unselects an option. When the Check Box is
checked, its value is set to 1 and when it is unchecked, the value is set to 0.
➢ You can include the statements Check1.Value=1 to mark the Check Box and Check1.Value=0 to
unmark the Check Box, as well as use them to initiate certain actions.
➢ In checkbox user can select more than one option.
➢ Multiple selections are allowed in checkbox.
Private Sub Command1_Click()
If Check1.Value = 1 And Check2.Value = 0 And Check3.Value = 0 Then
MsgBox "Apple is selected"
ElseIf Check2.Value = 1 And Check1.Value = 0 And Check3.Value = 0 Then
MsgBox "Orange is selected"
Else MsgBox "All are selected"
End If
End Sub
VISUAL BASIC CONTROLS
Prof. K. Adisesha (Ph. D)
37
CHECKBOX CONTROL :
The most common event associated with the Check Box is the Click event.
Check
Box
Properties Methods Events
Alignment, Appearance, BackColor, Caption,
Container, DataChanged, DataField,
DataSource, DragIcon, DragMode, Enabled,
Font, FontBold, FontItalic, FontName,
FontSize, FontStrikethru, FontUnderline,
ForeColor, Height, HelpContextID, hWnd,
Index, Left, MousePointer, Name, Parent,
TabIndex, TabStop, Tag, Top, Value, Visible,
WhatsThisHelpID, Width
Drag,
Move,
Refresh,
SetFocus,
ShowWhatsThis,
ZOrder
Click, DragDrop,
DragOver, GotFocus,
KeyDown, KeyPress,
KeyUp, LostFocus,
MouseDown,
MouseMove,
MouseUp
VISUAL BASIC CONTROLS
Prof. K. Adisesha (Ph. D)
38
OPTION BUTTON CONTROL :
OptionButton controls are also known as radio buttons because of their shape.
➢ You always use OptionButton controls in a group of two or more because their purpose is to
offer a number of mutually exclusive choices.
➢ Anytime you click on a button in the group, it switches to a selected state and all the other
controls in the group become unselected. Its value is set to “True” and when it is unselected; its
value is set to “False”.
Private Sub Command1_Click()
If Option1.Value = True Then
Form1.BackColor = vbRed
ElseIf Option2.Value = True Then
Form1.BackColor = vbBlue
Else Form1.BackColor = vbGreen
End If
End Sub
VISUAL BASIC CONTROLS
Prof. K. Adisesha (Ph. D)
39
OPTION BUTTON CONTROL :
The most common event associated with the Option Button is the Click event.
Check
Box
Properties Methods Events
Alignment, Appearance, BackColor, Caption,
Container, DragIcon, DragMode, Enabled,
Font, FontBold, FontItalic, FontName,
FontSize, FontStrikethru, FontUnderline,
ForeColor, Height, HelpContextID, hWnd,
Index, Left, MouseIcon, MousePointer, Name,
Parent, TabIndex, TabStop, Tag, Top,
Value, Visible, WhatsThisHelpID, Width
Drag, Move,
Refresh,
SetFocus,
ShowWhatsThis,
Zorder
Click, DblClick,
DragDrop, DragOver,
GotFocus, KeyDown,
KeyPress, KeyUp,
LostFocus, MouseDown,
MouseMove, MouseUp
VISUAL BASIC CONTROLS
Prof. K. Adisesha (Ph. D)
40
COMBOBOX CONTROL :
A combobox control is combination of textbox and listbox. This control enables user to select
either by typing in the text into combobox or by selecting items from the list..
➢ The function of the Combo Box is also to present a list of items where the user can click and
select the items from the list.
➢ In order to add items to the list, you can also use the AddItem method.
➢ Combobox is collapsed and it does not displays all the items.
➢ The combobox controls has three different style that can be set.
a) Drop down combo (style 0)
b) Simple combo (style 1)
c) Drop down list (style 2)
Combo1.AddItemitem number/string
VISUAL BASIC CONTROLS
Prof. K. Adisesha (Ph. D)
41
COMBOBOX CONTROL :
A combobox control is combination of textbox and listbox. This control enables user to select
either by typing in the text into combobox or by selecting items from the list..
➢ Drop down combo: The Dropdown Combo box first appears as only an edit area with a down
arrow button at the right. The user can either select a value from the list or type a value in the
edit area.
➢ Simple combo : The Simple Combo box displays an edit area with an attached list box always
visible immediately below the edit area. A simple combo box displays the contents of its list all
the time. A scroll bar is displayed beside the list if there are too many items to be displayed in the
list box area.
➢ Drop down list : The Dropdown list combo box turns the combo box into a Dropdown list box.
At run time, the control looks like the Dropdown combo box. The user could click the down
arrow to view the list.
VISUAL BASIC CONTROLS
Prof. K. Adisesha (Ph. D)
42
COMBOBOX CONTROL :
VISUAL BASIC CONTROLS
Prof. K. Adisesha (Ph. D)
43
COMBOBOX CONTROL :
VISUAL BASIC CONTROLS
Prof. K. Adisesha (Ph. D)
44
COMBOBOX CONTROL :
VISUAL BASIC CONTROLS
Prof. K. Adisesha (Ph. D)
45
COMBOBOX CONTROL :
VISUAL BASIC CONTROLS
Prof. K. Adisesha (Ph. D)
46
COMBOBOX CONTROL :
VISUAL BASIC CONTROLS
Prof. K. Adisesha (Ph. D)
47
COMBOBOX CONTROL :
VISUAL BASIC CONTROLS
Prof. K. Adisesha (Ph. D)
48
COMBOBOX CONTROL :
VISUAL BASIC CONTROLS
Prof. K. Adisesha (Ph. D)
49
LISTBOX CONTROL :
ListBox present a list of choices that are displayed vertically in single column, if number of items
exist the value can be displayed scrollbar automatically appear on control. Listbox is expanded
and displays all the items.
➢ ListBox have list property contain list or item to display.
➢ To add the item at design time, click on list property & add item, press ctrl + enter after adding
each item.
➢ To add item at runtime to AddItem method is used.
List1.AddItemitem number/string
➢ To remove item at runtime to RemoveItem method is used.
List1.RemoveItem index
List1.clear
VISUAL BASIC CONTROLS
Prof. K. Adisesha (Ph. D)
50
Difference between Listbox & Combobox.
➢ List Box :
1. Occupies more space but shows more than one value.
2. We can select multiple items.
3. we can use checkboxes with in the list box.
4. Listbox is much easier to handle.
5. We can't add image item in listbox.
➢ Combo Box:
1. Occupies less space but shows only one value for visibility
2. Multiple select is not possible
3. can't use checkboxes within combo boxes
4. combobox is not easier to handle.
5. we can add image item in combobox
VISUAL BASIC CONTROLS
Prof. K. Adisesha (Ph. D)
51
HSCROLLBAR & VSCROLLBAR.
The ScrollBar is a commonly used control, which enables the user to select a value by
positioning it at the desired location.
➢ The Min and Max property represents the minimum and maximum value.
➢ The value property of the ScrollBar represents its current value, that may be any integer between
minimum and maximum values assigned.
➢ Horizontal and vertical scroll bars are widely used in Windows applications.
➢ Scroll bars provide an intuitive way to move through a list of information and make great input
devices.
➢ Both type of scroll bars are comprised of three areas that can be clicked, or dragged, to change
the scroll bar value. Those areas are:
VISUAL BASIC CONTROLS
Prof. K. Adisesha (Ph. D)
52
Scroll Bar Properties:
➢ LargeChange: Increment added to or subtracted from the scroll bar Value property when the bar
area is clicked.
➢ Max : The value of the horizontal scroll bar at the far right and the value of the vertical scroll
bar at the bottom. Can range from -32,768 to 32,767.
➢ Min : The other extreme value - the horizontal scroll bar at the left and the vertical scroll bar at
the top. Can range from -32,768 to 32,767.
➢ SmallChange : The increment added to or subtracted from the scroll bar Value property when
either of the scroll arrows is clicked.
➢ Value : The current position of the scroll box (thumb) within the scroll bar. If you set this in
code, Visual Basic moves the scroll box to the proper position.
VISUAL BASIC CONTROLS
Prof. K. Adisesha (Ph. D)
53
TIMER CONTROL:
A Timer control is invisible at run time, and its purpose is to send a periodic pulse to the current
application.
You can trap this pulse by writing code in the Timer's Timer event procedure and take advantage of
it to execute a task in the background or to monitor a user's actions.
Timer Properties:
➢ Enabled : Used to turn the timer on and off. When on, it continues to operate until the Enabled
property is set to False.
➢ Interval : Number of milliseconds between each invocation of the Timer
Event.
➢ Timer Events: The timer tool only has one event, Timer. It has the form:
Private Sub Timer1_Timer()
Image1.Visible = True
End Sub
VISUAL BASIC CONTROLS
Prof. K. Adisesha (Ph. D)
54
DRIVELISTBOX:
The drive list box control allows a user to select a valid disk drive at run-time. The DriveListBox
is for displaying a list of drives available in your computer.
We use the box to get the current drive identification. DriveListBox control is a combobox-like
control that's automatically filled with your drive's letters and volume labels.
Drive List Box Properties:
➢ Drive: Contains the name of the currently selected drive.
Drive List Box Events:
➢ Change: Triggered whenever the user or program changes the drive selection
VISUAL BASIC CONTROLS
Prof. K. Adisesha (Ph. D)
55
DIRLISTBOX:
The DirListBox means the Directory List Box. It is for displaying a list of directories or folders in
a selected drive. When you place this control into the form and run the program, you will be able
to select different directories from a selected drive in your computer.
➢ The DirListBox is a special list box that displays a directory tree. The directory list box displays
an ordered, hierarchical list of the user's disk directories and subdirectories.
Directory List Box Properties::
➢ Path: Contains the current directory path.
Directory List Box Events:
➢ Change: Triggered when the directory selection is changed.
VISUAL BASIC CONTROLS
Prof. K. Adisesha (Ph. D)
56
FILELISTBOX:
The file list box locates and lists files in the directory specified by its Path property at run-time.
You may select the types of files you want to display in the file list box.
➢ The FileListBox control is a special-purpose ListBox control that displays all the files in a given
directory, optionally filtering them based on their names, extensions, and attributes.
File List Box Properties:
➢ FileName: Contains the currently selected file name.
➢ Pattern: Contains a string that determines which files will be displayed. It supports the use of *
and ? wildcard characters.
➢ Path: Contains the current path directory.
File List Box Events:
➢ DblClick: Triggered whenever a file name is double-clicked.
➢ PathChange: Triggered whenever the path changes in a file list box.
VISUAL BASIC CONTROLS
Prof. K. Adisesha (Ph. D)
57
Example:
VISUAL BASIC CONTROLS
Prof. K. Adisesha (Ph. D)
58
SHAPE CONTROL:
The shape tool can create circles, ovals, squares, rectangles, and rounded squares and
rectangles. Colors can be used and various fill patterns are available.
➢ It can display six basic shapes: Rectangle, Square, Oval, Circle, Rounded Rectangle, and
Rounded Square.
Shape Tool Properties:
➢ BackColor: Determines the background color of the shape.
➢ BackStyle: Determines whether the background is transparent or opaque.
➢ BorderColor: Determines the color of the shape's outline.
➢ BorderStyle: Determines the style of the shape's outline.
➢ BorderWidth: Determines the width of the shape border line.
➢ FillColor: Defines the interior color of the shape.
➢ FillStyle: Determines the interior pattern of a shape.
➢ Shape: Determines whether the shape is a square, rectangle, circle, or some other choice.
VISUAL BASIC CONTROLS
Prof. K. Adisesha (Ph. D)
59
ActiveX controls:
ActiveX controls are COM components or objects you can insert into a application to
reuse packaged functionality someone else has programmed.
➢ You can use ActiveX controls developed for Visual
Basic 6.0 to add features to the Toolbox.
➢ To add ActiveX controls to the toolbox
❖ On the Tools menu, click Choose Toolbox Items.
❖ The Choose Toolbox dialog box appears.
❖ Click the COM Components tab.
❖ Select the check box next to the ActiveX control
you want to use, and then click OK.
VISUAL BASIC CONTROLS
Prof. K. Adisesha (Ph. D)
60
Common Dialog control:
The common dialog control provides a standard set of dialog boxes for operations such
as opening and saving files, setting print options, and selecting colors and fonts.
➢ You use the common dialog control in your application by adding it to a form and setting
its properties.
➢ The common dialog control allows you to display these commonly used dialog boxes:
❖ Open
❖ Save As
❖ Color
❖ Font
❖ Print
VISUAL BASIC CONTROLS
Prof. K. Adisesha (Ph. D)
61
Common Dialog control:
The common dialog control provides a standard set of dialog boxes for operations such
as opening and saving files, setting print options, and selecting colors and fonts.
Discussion
Prof. K. Adisesha (Ph. D)
62
Queries ?
Prof. K. Adisesha
9449081542

More Related Content

Similar to VB PPT by ADI PART4.pdf

Practicalfileofvb workshop
Practicalfileofvb workshopPracticalfileofvb workshop
Practicalfileofvb workshopdhi her
 
The visual studio start page is shown in the figure below
The visual studio start page is shown in the figure belowThe visual studio start page is shown in the figure below
The visual studio start page is shown in the figure belowTan Ps
 
Unit IV-Checkboxes and Radio Buttons in VB.Net in VB.NET
Unit IV-Checkboxes    and   Radio Buttons in VB.Net in VB.NET Unit IV-Checkboxes    and   Radio Buttons in VB.Net in VB.NET
Unit IV-Checkboxes and Radio Buttons in VB.Net in VB.NET Ujwala Junghare
 
VB.Net-Controls and events
VB.Net-Controls and eventsVB.Net-Controls and events
VB.Net-Controls and eventsPrachi Sasankar
 
Interactive material
Interactive materialInteractive material
Interactive materialAnoo Al-henai
 
Adobe Illustrator CS5 Part 1 : Introduction to Illustrator
Adobe Illustrator CS5 Part 1 : Introduction to IllustratorAdobe Illustrator CS5 Part 1 : Introduction to Illustrator
Adobe Illustrator CS5 Part 1 : Introduction to Illustratorcsula its training
 
Buttons In .net Visual Basic
Buttons In .net Visual BasicButtons In .net Visual Basic
Buttons In .net Visual Basicmanish maurya
 
VensimPLE Quick Reference and Tutorial
VensimPLE Quick Reference and TutorialVensimPLE Quick Reference and Tutorial
VensimPLE Quick Reference and Tutorialjiali zhang
 
CheckBox In C#.pptx
CheckBox In C#.pptxCheckBox In C#.pptx
CheckBox In C#.pptxSlemanIsmail
 
Ajp notes-chapter-01
Ajp notes-chapter-01Ajp notes-chapter-01
Ajp notes-chapter-01Ankit Dubey
 

Similar to VB PPT by ADI PART4.pdf (20)

Practicalfileofvb workshop
Practicalfileofvb workshopPracticalfileofvb workshop
Practicalfileofvb workshop
 
The visual studio start page is shown in the figure below
The visual studio start page is shown in the figure belowThe visual studio start page is shown in the figure below
The visual studio start page is shown in the figure below
 
Unit IV-Checkboxes and Radio Buttons in VB.Net in VB.NET
Unit IV-Checkboxes    and   Radio Buttons in VB.Net in VB.NET Unit IV-Checkboxes    and   Radio Buttons in VB.Net in VB.NET
Unit IV-Checkboxes and Radio Buttons in VB.Net in VB.NET
 
Visual studio.net
Visual studio.netVisual studio.net
Visual studio.net
 
VB.Net-Controls and events
VB.Net-Controls and eventsVB.Net-Controls and events
VB.Net-Controls and events
 
VB PPT by ADI part-1.pdf
VB PPT by ADI part-1.pdfVB PPT by ADI part-1.pdf
VB PPT by ADI part-1.pdf
 
Windowforms controls c#
Windowforms controls c#Windowforms controls c#
Windowforms controls c#
 
Gui
GuiGui
Gui
 
Vs c# lecture1
Vs c# lecture1Vs c# lecture1
Vs c# lecture1
 
Interactive material
Interactive materialInteractive material
Interactive material
 
Visual basic
Visual basicVisual basic
Visual basic
 
Windows note(43 69)
Windows note(43 69)Windows note(43 69)
Windows note(43 69)
 
Unit2
Unit2Unit2
Unit2
 
Adobe Illustrator CS5 Part 1 : Introduction to Illustrator
Adobe Illustrator CS5 Part 1 : Introduction to IllustratorAdobe Illustrator CS5 Part 1 : Introduction to Illustrator
Adobe Illustrator CS5 Part 1 : Introduction to Illustrator
 
Buttons In .net Visual Basic
Buttons In .net Visual BasicButtons In .net Visual Basic
Buttons In .net Visual Basic
 
VensimPLE Quick Reference and Tutorial
VensimPLE Quick Reference and TutorialVensimPLE Quick Reference and Tutorial
VensimPLE Quick Reference and Tutorial
 
CheckBox In C#.pptx
CheckBox In C#.pptxCheckBox In C#.pptx
CheckBox In C#.pptx
 
Visual basic
Visual basicVisual basic
Visual basic
 
Ajp notes-chapter-01
Ajp notes-chapter-01Ajp notes-chapter-01
Ajp notes-chapter-01
 
2 front panel
2  front panel2  front panel
2 front panel
 

More from AdiseshaK

Introduction to Java Programming.pdf
Introduction to Java Programming.pdfIntroduction to Java Programming.pdf
Introduction to Java Programming.pdfAdiseshaK
 
SP_Solutions_-Adi.pdf
SP_Solutions_-Adi.pdfSP_Solutions_-Adi.pdf
SP_Solutions_-Adi.pdfAdiseshaK
 
CNS_Solutions-Adi.pdf
CNS_Solutions-Adi.pdfCNS_Solutions-Adi.pdf
CNS_Solutions-Adi.pdfAdiseshaK
 
TOC_Solutions-Adi.pdf
TOC_Solutions-Adi.pdfTOC_Solutions-Adi.pdf
TOC_Solutions-Adi.pdfAdiseshaK
 
INPUT OUTPUT MEMORY DEVICE.pdf
INPUT OUTPUT MEMORY DEVICE.pdfINPUT OUTPUT MEMORY DEVICE.pdf
INPUT OUTPUT MEMORY DEVICE.pdfAdiseshaK
 
Macros & Loaders sp.pdf
Macros & Loaders sp.pdfMacros & Loaders sp.pdf
Macros & Loaders sp.pdfAdiseshaK
 
COMPILER DESIGN.pdf
COMPILER DESIGN.pdfCOMPILER DESIGN.pdf
COMPILER DESIGN.pdfAdiseshaK
 
Introd to loaders_sp Adi.pdf
Introd to loaders_sp Adi.pdfIntrod to loaders_sp Adi.pdf
Introd to loaders_sp Adi.pdfAdiseshaK
 
Assembler by ADI.pdf
Assembler by ADI.pdfAssembler by ADI.pdf
Assembler by ADI.pdfAdiseshaK
 
C programming notes.pdf
C programming notes.pdfC programming notes.pdf
C programming notes.pdfAdiseshaK
 
VB PPT by ADI PART3.pdf
VB PPT by ADI PART3.pdfVB PPT by ADI PART3.pdf
VB PPT by ADI PART3.pdfAdiseshaK
 
WP Solutions- Adi.pdf
WP Solutions- Adi.pdfWP Solutions- Adi.pdf
WP Solutions- Adi.pdfAdiseshaK
 
TOC Solutions-Adi.pdf
TOC Solutions-Adi.pdfTOC Solutions-Adi.pdf
TOC Solutions-Adi.pdfAdiseshaK
 
SP Solutions -Adi.pdf
SP Solutions -Adi.pdfSP Solutions -Adi.pdf
SP Solutions -Adi.pdfAdiseshaK
 
CNS Solutions-Adi.pdf
CNS Solutions-Adi.pdfCNS Solutions-Adi.pdf
CNS Solutions-Adi.pdfAdiseshaK
 
VB PPT by ADI PART2.pdf
VB PPT by ADI PART2.pdfVB PPT by ADI PART2.pdf
VB PPT by ADI PART2.pdfAdiseshaK
 
VB PPT by ADI part-1.pdf
VB PPT by ADI part-1.pdfVB PPT by ADI part-1.pdf
VB PPT by ADI part-1.pdfAdiseshaK
 
8085 microprocessor notes
8085 microprocessor notes8085 microprocessor notes
8085 microprocessor notesAdiseshaK
 
Introduction to 8085_by_adi_ppt
Introduction to 8085_by_adi_pptIntroduction to 8085_by_adi_ppt
Introduction to 8085_by_adi_pptAdiseshaK
 

More from AdiseshaK (20)

Introduction to Java Programming.pdf
Introduction to Java Programming.pdfIntroduction to Java Programming.pdf
Introduction to Java Programming.pdf
 
SP_Solutions_-Adi.pdf
SP_Solutions_-Adi.pdfSP_Solutions_-Adi.pdf
SP_Solutions_-Adi.pdf
 
CNS_Solutions-Adi.pdf
CNS_Solutions-Adi.pdfCNS_Solutions-Adi.pdf
CNS_Solutions-Adi.pdf
 
TOC_Solutions-Adi.pdf
TOC_Solutions-Adi.pdfTOC_Solutions-Adi.pdf
TOC_Solutions-Adi.pdf
 
INPUT OUTPUT MEMORY DEVICE.pdf
INPUT OUTPUT MEMORY DEVICE.pdfINPUT OUTPUT MEMORY DEVICE.pdf
INPUT OUTPUT MEMORY DEVICE.pdf
 
AI-ML.pdf
AI-ML.pdfAI-ML.pdf
AI-ML.pdf
 
Macros & Loaders sp.pdf
Macros & Loaders sp.pdfMacros & Loaders sp.pdf
Macros & Loaders sp.pdf
 
COMPILER DESIGN.pdf
COMPILER DESIGN.pdfCOMPILER DESIGN.pdf
COMPILER DESIGN.pdf
 
Introd to loaders_sp Adi.pdf
Introd to loaders_sp Adi.pdfIntrod to loaders_sp Adi.pdf
Introd to loaders_sp Adi.pdf
 
Assembler by ADI.pdf
Assembler by ADI.pdfAssembler by ADI.pdf
Assembler by ADI.pdf
 
C programming notes.pdf
C programming notes.pdfC programming notes.pdf
C programming notes.pdf
 
VB PPT by ADI PART3.pdf
VB PPT by ADI PART3.pdfVB PPT by ADI PART3.pdf
VB PPT by ADI PART3.pdf
 
WP Solutions- Adi.pdf
WP Solutions- Adi.pdfWP Solutions- Adi.pdf
WP Solutions- Adi.pdf
 
TOC Solutions-Adi.pdf
TOC Solutions-Adi.pdfTOC Solutions-Adi.pdf
TOC Solutions-Adi.pdf
 
SP Solutions -Adi.pdf
SP Solutions -Adi.pdfSP Solutions -Adi.pdf
SP Solutions -Adi.pdf
 
CNS Solutions-Adi.pdf
CNS Solutions-Adi.pdfCNS Solutions-Adi.pdf
CNS Solutions-Adi.pdf
 
VB PPT by ADI PART2.pdf
VB PPT by ADI PART2.pdfVB PPT by ADI PART2.pdf
VB PPT by ADI PART2.pdf
 
VB PPT by ADI part-1.pdf
VB PPT by ADI part-1.pdfVB PPT by ADI part-1.pdf
VB PPT by ADI part-1.pdf
 
8085 microprocessor notes
8085 microprocessor notes8085 microprocessor notes
8085 microprocessor notes
 
Introduction to 8085_by_adi_ppt
Introduction to 8085_by_adi_pptIntroduction to 8085_by_adi_ppt
Introduction to 8085_by_adi_ppt
 

Recently uploaded

mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpinRaunakKeshri1
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...RKavithamani
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 

Recently uploaded (20)

mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 

VB PPT by ADI PART4.pdf

  • 2. Introduction to Part-4 Introduction Builtin Functions Queries Tool Box Form Controls 2 Visual Basic 6 CONTROL PROPERTIES Prof. K. Adisesha (Ph. D) Event Controls
  • 3. VISUAL BASIC FUNCTIONS Prof. K. Adisesha (Ph. D) 3 Built in Functions: Built in functions in VB are classified into following types. ➢ Input Box Function ➢ MsgBox Function
  • 4. VISUAL BASIC FUNCTIONS Prof. K. Adisesha (Ph. D) 4 MessageBox Function In Visual Basic: Displays a message in a dialog box and wait for the user to click a button, and returns an integer indicating which button the user clicked. ➢ Following is an expanded MessageBox- ➢ Syntax : MsgBox ( Prompt [,icons+buttons ] [,title ] ) variable = MsgBox ( prompt [, icons+ buttons] [,title] ) ➢ Prompt : String expressions displayed as the message in the dialog box. ➢ Icons + Buttons : Numeric expression that is the sum of values specifying the number and type of buttons and icon to display. ➢ Title : String expression displayed in the title bar of the dialog box. If you omit title, the application name is placed in the title bar.
  • 5. VISUAL BASIC FUNCTIONS Prof. K. Adisesha (Ph. D) 5 MessageBox Function In Visual Basic: ➢ Following is an expanded MessageBox- ➢ Syntax :a = MsgBox(“Are you sure", 16 + 4, “Warning") ➢ Buttons Constant Value Description vbCritical 16 Display Critical message icon vbQuestion 32 Display Warning Query icon vbExclamation 48 Display Warning message icon vbInformation 64 Display information icon Constant Value Description vbOkOnly 0 Display OK button only vbOkCancel 1 Display OK and Cancel buttons vbAbortRetryIgnore 2 Display Abort, Retry and Ignore buttons vbYesNoCancel 3 Display Yes, No and Cancel buttons vbYesNo 4 Display Yes and No buttons vbRetryCancel 5 Display Retry and Cancel buttons ➢ Icons
  • 6. VISUAL BASIC FUNCTIONS Prof. K. Adisesha (Ph. D) 6 InputBox Function In Visual Basic: Displays a prompt in a dialog box, waits for the user to input text or click a button, and returns a String containing the contents of the text box. ➢ Syntax : variable = InputBox (prompt[,title][,default]) ans = InputBox("Enter message”, "Testing", 0) ➢ Prompt : String expression displayed as the message in the dialog box. ➢ Title - String expression displayed in the title bar of the dialog box. If you omit the title, the application name is displayed in the title bar ➢ default-text - The default text that appears in the input field where users can use it as his intended input or he may change to the message he wish to key in. ➢ x-position and y-position - the position or the coordinate of the input box.
  • 7. VISUAL BASIC CONTROLS Prof. K. Adisesha (Ph. D) 7 Control Property:
  • 8. VISUAL BASIC CONTROLS Prof. K. Adisesha (Ph. D) 8 Toolbox Window: The Tool box contains the icons of the controls you can place on a form to create the application's User Interface. ➢ By default, the Toolbox contains the pointer icon and the icons of 20 ActiveX controls. ➢ Pointer : The pointer is not a control but can be used with the controls on the form i.e. resize, move them etc. ➢ Picture Box: This control is used to display images. The images are set with the picture property of this control. ➢ Label : This control is used to display text that the user cannot edit it. The text is set with the caption property of this control. Normally this control is used to display names, initial values at design time and program results at run time through the code.
  • 9. VISUAL BASIC CONTROLS Prof. K. Adisesha (Ph. D) 9 Toolbox Window: The Tool box contains the icons of the controls you can place on a form to create the application's User Interface. ➢ TextBox : This control displays text that the user can edit. The text is set with the text property of this control. This control normally used to accept the inputs from the user and also to display program results to the user. ➢ Frame : This control is used to group the other controls. It used to draw boxes on the form and other required controls can be placed inside this box area making a group of controls on the form. ➢ CommandButton : A command button represents an action that is carried out when the user clicks the button. Action is associated with the click event of this control in program code. ➢ CheckBox : This control is used to provide a choice of selection to the user. It shows a check (or right) mark on one click and clears on another click i.e. it toggles (or changes) on every click.
  • 10. VISUAL BASIC CONTROLS Prof. K. Adisesha (Ph. D) 10 Toolbox Window: The Tool box contains the icons of the controls you can place on a form to create the application's User Interface. ➢ OptionButtons: This control also called as radio button is used to provide a choice of action to the ➢ user. It shows a small shaded dot like circle when selected and cleared when not selected The value property is used to on and off like car radio button. ➢ ListBox : This control provides a list of text items from which the user can select one or more. The text cannot be edited by the user, but on selection, the selected item's text can be used to display. ➢ ComboBox : This control is similar to ListBox control but it contains text edit field. The user can select an item from the list like ListBox control or enter new text in the edit field. ➢ Horizontal and Vertical ScrollBars : These controls similar to familiar scroll bars found in many of the applications. These can be used to scroll the contents of controls those do not have built-in vertical and horizontal scroll bar properties.
  • 11. VISUAL BASIC CONTROLS Prof. K. Adisesha (Ph. D) 11 Toolbox Window: The Tool box contains the icons of the controls you can place on a form to create the application's User Interface. ➢ Timer: This control facilitates the user to schedule certain events in the program. It has the facility to set time intervals. The interval property of this control is set to schedule the events. ➢ Shape : This control is used to draw graphical elements, such as rectangles, circles, and squares on the form. ➢ Line : Similar to the shape control, the line control can be used to draw the straight lines on the form. ➢ Image : This control can be used to display image. This control is similar to the Picture Box control but has minimum number of facilities than the Picture Box control. ➢ Data : This control is used to connect databases. This has many properties and methods to facilitate data access.
  • 12. VISUAL BASIC CONTROLS Prof. K. Adisesha (Ph. D) 12 Toolbox Window: The Tool box contains the icons of the controls you can place on a form to create the application's User Interface. ➢ OLE: Three controls namely, DrivelistBox, DirectoryListBox. and FileListBox are extending ➢ the users ability to handle file system of the system. ➢ File system related controls : This control can be used to display image. This control is similar to the Picture Box control but has minimum number of facilities than the Picture Box control. ❖ DrivelistBox : This control displays the drives on the system in a drop-down list form. The user can select any drive from the list. ❖ DirectoryListBox : This control displays a list of all folders in the current drive and lets the user move up or down in the hierarchy of the folders. ❖ FileListBox : This control displays a list of all files in the current folder or directory.
  • 13. Property Property Left The position of the left side of a control with respect to its container Top The position of the top of a control with respect to its container Height A control's height Width A control's width Name The string value used to refer to a control Enabled The Boolean (True/False) value that determines whether users can manipulate the control Visible The Boolean (True/False) value that determines whether users can see the control VISUAL BASIC CONTROLS Prof. K. Adisesha (Ph. D) 13 Common properties, methods and events of controls: Every object, such as a form or control, has a set of properties that describe it. ➢ Although this set isn't identical for all objects, some properties.
  • 14. VISUAL BASIC CONTROLS Prof. K. Adisesha (Ph. D) 14 Common Events of controls: Events are what happen in and around your program. For example, when a user clicks a button, many events occur. ➢ The mouse button is pressed, the CommandButton in your program is clicked, and then the mouse button is released. ➢ These events occur as a result of some specific user action, such as moving the mouse, pressing a key on the keyboard, or clicking a text box. ➢ These types of events are user-initiated events and are what you will write code for most often. ➢ Example of Click event for CommandButton Private Sub Command1_Click() Print "Click event activated" End Sub ➢ When the user clicks on the commandbutton1 “Click event activated” will print on the form.
  • 15. Event Occurrence Change The user modifies text in a combo box or text box Click The user clicks the primary mouse button on an object. DblClick The user double-clicks the primary mouse button on an object. DragDrop The user drags an object to another location. DragOver The user drags an object over another control. KeyPress The user presses and releases a keyboard key while an object has focus. GotFocus & LostFocus An object receives focus & An object loses focus. MouseMove The user moves the mouse pointer over an object. VISUAL BASIC CONTROLS Prof. K. Adisesha (Ph. D) 15 Common Events of Visual Basic Controls: ➢ Although this set isn't identical for all objects, some Event Controls.
  • 16. VISUAL BASIC CONTROLS Prof. K. Adisesha (Ph. D) 16 Methods: Methods are blocks of code designed into a control that tell the control how to do things, such as move to another location on a form. ➢ Just as with properties, not all controls have the same methods, although some common methods do exist. Common Methods of Visual Basic Controls: Method Use Move Changes an object's position in response to a code request Drag Handles the execution of a drag-and-drop operation by the user SetFocus Gives focus to the object specified in the method call ZOrder Determines the order in which multiple objects appear onscreen
  • 17. Event Occurrence Change The user modifies text in a combo box or text box Click The user clicks the primary mouse button on an object. DblClick The user double-clicks the primary mouse button on an object. DragDrop The user drags an object to another location. DragOver The user drags an object over another control. KeyPress The user presses and releases a keyboard key while an object has focus. GotFocus & LostFocus An object receives focus & An object loses focus. MouseMove The user moves the mouse pointer over an object. VISUAL BASIC CONTROLS Prof. K. Adisesha (Ph. D) 17 Common Events of Visual Basic Event Controls: ➢ Although this set isn't identical for all objects, some Event Controls.
  • 18. VISUAL BASIC CONTROLS Prof. K. Adisesha (Ph. D) 18 Form Control Properties: The controls or objects viewed as user interface elements have set of properties. Visual Basic assigns default properties to every new control you place on a form. ➢ Few properties are available only at design time and a few properties available only at run time. Some run time properties are read only. ➢ The properties of the control are accessed with the syntax consisting control's name followed by a period followed by property as shown Controlname.property Form Properties: Name, Caption, Appearance, BackColor, BorderStyle, Picture, Movable, Height, Width, Left, Top, Visible :
  • 19. VISUAL BASIC CONTROLS Prof. K. Adisesha (Ph. D) 19 The following properties apply to Form objects: ➢ Name : This property sets the name of the control, through which you can access the control's properties and methods in the program code. ➢ Appearance : It has Two Values ❖ • If it is Set to 1-3D ,it allows to set 3-D Appearance at run time. ❖ • If it is Set to 0-Flat , it allows only 2-D Effects at run time Example : Form1.Appearance = 1 or Form1.Appearance = 0 ➢ Caption : This property sets the text that is displayed on many controls or used to display text in the title of the control. Example : Form1.Caption = "form title“ ➢ Font : This property sets the face, attribute, and size of the font used for the text on the control. Example : Form1.Font = "Arial" Form1.FontSize = 50
  • 20. VISUAL BASIC CONTROLS Prof. K. Adisesha (Ph. D) 20 The following properties apply to Form objects: ➢ BorderStyle : The BorderStyle Property determine the style of the form’s border and appearance of then form. ➢ The BorderStyle Property can take one of the values shown in below table ❖ 0 – none : Form Cant be resized and move at run time. ❖ 1 - Fixed single : Cant be resized but we can move. ❖ 2 – Sizeable : User can resize and move the form. ❖ 3 – Fixed dialog : User cant resize the form. ❖ 4 – Fixed tool window : Similar to fixed dialog. Example : Form1.BorderStyle = 2 ➢ BackColor : This property sets the background color of the control. Example : Form1.BackColor = vbRed ➢ ForeColor : This property sets the foreground color of the control. Example : Form1.ForeColor = vbRed
  • 21. VISUAL BASIC CONTROLS Prof. K. Adisesha (Ph. D) 21 The following properties apply to Form objects: ➢ Text: This property sets the text that is displayed on the controls that accept user input, Example : Text1.Text = "TextBox Topic Explanation“ ➢ Width, Height : : These properties set the control's dimensions. ❖ Height : To change the height of the control. ❖ Width : The width of control can be change. Example : Form1.Height = 500 Form1.Width = 500 ➢ Left, Top : These properties set the conditions of the control's upper-left corner, expressed in the units of the container (usually a form). ❖ Left : It determines the distance of the control from the left of the screen. ❖ Top : It determines the distance of the control from the top of the screen. Example : Form1.Left = 100 Form1.Top = 100
  • 22. VISUAL BASIC CONTROLS Prof. K. Adisesha (Ph. D) 22 The following properties apply to Form objects: ➢ Enabled: By default, this property's value is true, which means that the control can get the focus. If it is set to false the control is disabled. , Example : Form1.Enabled = True Form1.Enabled = False ➢ Picture : This is property sets/restes a graphic in the control. If a bitmap image is assigned to this property, the image is displayed on the control. ➢ Visible :Set this property to true to make a control visible. Set this property to false to make a control invisible. Example : Form1.Visible = True Form1.Visible = False
  • 23. VISUAL BASIC CONTROLS Prof. K. Adisesha (Ph. D) 23 Control's Methods : The Controls or objects have methods which are the actions carried out by them. These actions invoked from you with in your code. ➢ The following are the few common methods. ➢ Print : the Print method is used to display the text on the form Example : Form1.print “print method of form” ➢ Clear : The clear method tells the control to clear its contents On controls ➢ Example :The code that can be used in the program is as Form1.Clear ListBox1.Clear Clipboard.Clear
  • 24. VISUAL BASIC CONTROLS Prof. K. Adisesha (Ph. D) 24 The following properties apply to Pointer objects: ➢ MousePointer: returns or sets the type of mouse pointer displayed when mouse is moved over part of an object. Example : Form1.MousePointer = 1 ➢ Tag : Stores any extra data need for your program. ➢ ToolTipText : Allows the text to be displayed when mouse pointer is brought over the control. ➢ Tab Order: All windows applications allow the user to move the focus from one control to another
  • 25. VISUAL BASIC CONTROLS Prof. K. Adisesha (Ph. D) 25 Control's Methods : ➢ Move: All controls that are visible at run time provide Move method that lets you to move and resize them with in your code. The syntax of the move method is ControlName. Move left, top, width, height Example : Form1.Move 50,50,500,500 ➢ Refresh : This method when used forces a complete repaint of object. The syntax is Refresh( ) The use of this method with controls is control-name. refresh Example : form1.refresh ➢ Zorder : This method when used places a specified control or object at the front or back of the Z- order within its graphical level. The syntax is Zorder([Position]) Example : Form1.ZOrder(0) if it is zero, the object is placed front, if it is 1 the object is placed back of the control
  • 26. VISUAL BASIC CONTROLS Prof. K. Adisesha (Ph. D) 26 Control's Methods : ➢ Set Focus: This method when used moves the focus to the specified object. This method is present with the controls. where user interaction at run time is possible like TextBox control where user can enter text in it at run time. The syntax is Set Focus() The use of this method with controls is control-name. Set Focus Example : Form1.SetFocus Text1.SetFocus ➢ Show : The Show method is used to display the control. Example : Form1.show ➢ Hide: The Hide Method is opposite of show method that not displayed or hide the control Example : Form1.Hide
  • 27. VISUAL BASIC CONTROLS Prof. K. Adisesha (Ph. D) 27 Label Control Methods : The label is a very useful control for Visual Basic, as it is not only used to provide instructions and guides to the users, it can also be used to display outputs. One of its most important properties is Caption. Using the syntax Label.Caption, it can display text and numeric data. You can change its caption in the properties window and also at runtime. ➢ Some important Properties of Label Control: ❖ Caption - the text that is displayed in the label ❖ BackColor and ForeColor - colors of the background and the text ❖ BackStyle - Opaque or Transparent - whether the background is visible or not ❖ Font - font and size of text ❖ Alignment - text centered, left or right
  • 28. VISUAL BASIC CONTROLS Prof. K. Adisesha (Ph. D) 28 Label Control Methods :
  • 29. VISUAL BASIC CONTROLS Prof. K. Adisesha (Ph. D) 29 TextBox Control Methods : The TextBox is like a Label but, it is used to input data into the program. The data typed in is in the Text property of the control. TextBox controls offer a natural way for users to enter a value in your program. Private Sub Command1_Click() Sum = Val(Text1.Text) +Val(Text2.Text) Label1.Caption = Sum End Sub
  • 30. VISUAL BASIC CONTROLS Prof. K. Adisesha (Ph. D) 30 TextBox Control Methods : The following Figure summarizes the common TextBox control's properties and methods. Property Property Description Enabled specifies whether user can interact with this control or not Index Specifies the control array index Locked If this control is set to True user can use it else if this control is set to false the control cannot be used MaxLength Specifies the maximum number of characters to be input. Default value is set to 0 that means user can input any number of characters MousePointer Using this we can set the shape of the mouse pointer when over a TextBox Multiline Multiline By setting this property to True user can have more than one line in the TextBox PasswordChar This is to specify mask character to be displayed in the TextBox Text Specifies the text to be displayed in the TextBox at runtime
  • 31. VISUAL BASIC CONTROLS Prof. K. Adisesha (Ph. D) 31 TextBox Control Methods : The following Figure summarizes the common TextBox control's properties and methods. Events Event procedures Description Change Action happens when the TextBox changes Click Action happens when the TextBox is clicked GotFocus Action happens when the TextBox receives the active focus LostFocus Action happens when the TextBox loses it focus KeyDown Called when a key is pressed while the TextBox has the focus KeyUp Called when a key is released while the TextBox has the focus Methods SetFocus Transfers focus to the TextBox
  • 32. VISUAL BASIC CONTROLS Prof. K. Adisesha (Ph. D) 32 FRAME CONTROL : Frame controls are similar to Label controls in that they can serve as captions for those controls that don't have their own. Moreover, Frame controls can also behave as containers and host other controls. ➢ Controls that are contained in the Frame control are said to be child controls. Moving a control at design time over a Frame control—or over any other container. ➢ Frame controls, like all container controls, have two interesting features. ❖ If you move a Frame control, all the child controls go with it. ❖ If you make a container control disabled or invisible, all its child controls also become disabled or invisible.
  • 33. VISUAL BASIC CONTROLS Prof. K. Adisesha (Ph. D) 33 FRAME CONTROL : Frame controls are similar to Label controls in that they can serve as captions for those controls that don't have their own. Frame Properties Methods Events Appearance, BackColor, Caption, ClipControls, Container, DragIcon, DragMode, Enabled, Font, FontBold, FontItalic, FontName, FontSize, FontStrikethru, FontUnderline, ForeColor, Height, HelpContextID, hWnd, Index, Left, MouseIcon, MousePointer, Name, Parent, TabIndex, Tag, Top, Visible, WhatsThisHelpID, Width Drag, Move, Refresh, ShowWhatsThis, ZOrder Click, DblClick, DragDrop, DragOver, MouseDown, MouseMove, MouseUp
  • 34. VISUAL BASIC CONTROLS Prof. K. Adisesha (Ph. D) 34 COMMAND BUTTON CONTROL : The command button is one of the most important controls as it is used to execute commands. It displays an illusion that the button is pressed when the user click on it. ➢ The most common event associated with the command button is the Click event, and the syntax for the procedure is. ➢ The Caption property determines the text to display on the face of the button. Private Sub Command1_Click() Dim yourpassword As String yourpassword = Text1.Text MsgBox ("Your password is: " & yourpassword) End Sub
  • 35. VISUAL BASIC CONTROLS Prof. K. Adisesha (Ph. D) 35 COMMAND BUTTON CONTROL : The most common event associated with the command button is the Click event. Command Button Properties Methods Events Appearance, BackColor, Cancel, Caption, Container, Default, DragIcon, DragMode, Enabled, Font, FontBold, FontItalic, FontName, FontSize, FontStrikethru, FontUnderline, Height, HelpContextID, hWnd, Index, Left, MouseIcon, MousePointer, Name, Parent, Style, TabIndex, TabStop, Tag, Top, Value, Visible, WhatsThisHelpID, Width Drag, Move, Refresh, ShowWhatsThis, ZOrder Click, DragDrop, DragOver, GotFocus, KeyDown, KeyPress, KeyUp, LostFocus, MouseDown, MouseMove, MouseUp
  • 36. VISUAL BASIC CONTROLS Prof. K. Adisesha (Ph. D) 36 CHECKBOX CONTROL : The Check Box control lets the user selects or unselects an option. When the Check Box is checked, its value is set to 1 and when it is unchecked, the value is set to 0. ➢ You can include the statements Check1.Value=1 to mark the Check Box and Check1.Value=0 to unmark the Check Box, as well as use them to initiate certain actions. ➢ In checkbox user can select more than one option. ➢ Multiple selections are allowed in checkbox. Private Sub Command1_Click() If Check1.Value = 1 And Check2.Value = 0 And Check3.Value = 0 Then MsgBox "Apple is selected" ElseIf Check2.Value = 1 And Check1.Value = 0 And Check3.Value = 0 Then MsgBox "Orange is selected" Else MsgBox "All are selected" End If End Sub
  • 37. VISUAL BASIC CONTROLS Prof. K. Adisesha (Ph. D) 37 CHECKBOX CONTROL : The most common event associated with the Check Box is the Click event. Check Box Properties Methods Events Alignment, Appearance, BackColor, Caption, Container, DataChanged, DataField, DataSource, DragIcon, DragMode, Enabled, Font, FontBold, FontItalic, FontName, FontSize, FontStrikethru, FontUnderline, ForeColor, Height, HelpContextID, hWnd, Index, Left, MousePointer, Name, Parent, TabIndex, TabStop, Tag, Top, Value, Visible, WhatsThisHelpID, Width Drag, Move, Refresh, SetFocus, ShowWhatsThis, ZOrder Click, DragDrop, DragOver, GotFocus, KeyDown, KeyPress, KeyUp, LostFocus, MouseDown, MouseMove, MouseUp
  • 38. VISUAL BASIC CONTROLS Prof. K. Adisesha (Ph. D) 38 OPTION BUTTON CONTROL : OptionButton controls are also known as radio buttons because of their shape. ➢ You always use OptionButton controls in a group of two or more because their purpose is to offer a number of mutually exclusive choices. ➢ Anytime you click on a button in the group, it switches to a selected state and all the other controls in the group become unselected. Its value is set to “True” and when it is unselected; its value is set to “False”. Private Sub Command1_Click() If Option1.Value = True Then Form1.BackColor = vbRed ElseIf Option2.Value = True Then Form1.BackColor = vbBlue Else Form1.BackColor = vbGreen End If End Sub
  • 39. VISUAL BASIC CONTROLS Prof. K. Adisesha (Ph. D) 39 OPTION BUTTON CONTROL : The most common event associated with the Option Button is the Click event. Check Box Properties Methods Events Alignment, Appearance, BackColor, Caption, Container, DragIcon, DragMode, Enabled, Font, FontBold, FontItalic, FontName, FontSize, FontStrikethru, FontUnderline, ForeColor, Height, HelpContextID, hWnd, Index, Left, MouseIcon, MousePointer, Name, Parent, TabIndex, TabStop, Tag, Top, Value, Visible, WhatsThisHelpID, Width Drag, Move, Refresh, SetFocus, ShowWhatsThis, Zorder Click, DblClick, DragDrop, DragOver, GotFocus, KeyDown, KeyPress, KeyUp, LostFocus, MouseDown, MouseMove, MouseUp
  • 40. VISUAL BASIC CONTROLS Prof. K. Adisesha (Ph. D) 40 COMBOBOX CONTROL : A combobox control is combination of textbox and listbox. This control enables user to select either by typing in the text into combobox or by selecting items from the list.. ➢ The function of the Combo Box is also to present a list of items where the user can click and select the items from the list. ➢ In order to add items to the list, you can also use the AddItem method. ➢ Combobox is collapsed and it does not displays all the items. ➢ The combobox controls has three different style that can be set. a) Drop down combo (style 0) b) Simple combo (style 1) c) Drop down list (style 2) Combo1.AddItemitem number/string
  • 41. VISUAL BASIC CONTROLS Prof. K. Adisesha (Ph. D) 41 COMBOBOX CONTROL : A combobox control is combination of textbox and listbox. This control enables user to select either by typing in the text into combobox or by selecting items from the list.. ➢ Drop down combo: The Dropdown Combo box first appears as only an edit area with a down arrow button at the right. The user can either select a value from the list or type a value in the edit area. ➢ Simple combo : The Simple Combo box displays an edit area with an attached list box always visible immediately below the edit area. A simple combo box displays the contents of its list all the time. A scroll bar is displayed beside the list if there are too many items to be displayed in the list box area. ➢ Drop down list : The Dropdown list combo box turns the combo box into a Dropdown list box. At run time, the control looks like the Dropdown combo box. The user could click the down arrow to view the list.
  • 42. VISUAL BASIC CONTROLS Prof. K. Adisesha (Ph. D) 42 COMBOBOX CONTROL :
  • 43. VISUAL BASIC CONTROLS Prof. K. Adisesha (Ph. D) 43 COMBOBOX CONTROL :
  • 44. VISUAL BASIC CONTROLS Prof. K. Adisesha (Ph. D) 44 COMBOBOX CONTROL :
  • 45. VISUAL BASIC CONTROLS Prof. K. Adisesha (Ph. D) 45 COMBOBOX CONTROL :
  • 46. VISUAL BASIC CONTROLS Prof. K. Adisesha (Ph. D) 46 COMBOBOX CONTROL :
  • 47. VISUAL BASIC CONTROLS Prof. K. Adisesha (Ph. D) 47 COMBOBOX CONTROL :
  • 48. VISUAL BASIC CONTROLS Prof. K. Adisesha (Ph. D) 48 COMBOBOX CONTROL :
  • 49. VISUAL BASIC CONTROLS Prof. K. Adisesha (Ph. D) 49 LISTBOX CONTROL : ListBox present a list of choices that are displayed vertically in single column, if number of items exist the value can be displayed scrollbar automatically appear on control. Listbox is expanded and displays all the items. ➢ ListBox have list property contain list or item to display. ➢ To add the item at design time, click on list property & add item, press ctrl + enter after adding each item. ➢ To add item at runtime to AddItem method is used. List1.AddItemitem number/string ➢ To remove item at runtime to RemoveItem method is used. List1.RemoveItem index List1.clear
  • 50. VISUAL BASIC CONTROLS Prof. K. Adisesha (Ph. D) 50 Difference between Listbox & Combobox. ➢ List Box : 1. Occupies more space but shows more than one value. 2. We can select multiple items. 3. we can use checkboxes with in the list box. 4. Listbox is much easier to handle. 5. We can't add image item in listbox. ➢ Combo Box: 1. Occupies less space but shows only one value for visibility 2. Multiple select is not possible 3. can't use checkboxes within combo boxes 4. combobox is not easier to handle. 5. we can add image item in combobox
  • 51. VISUAL BASIC CONTROLS Prof. K. Adisesha (Ph. D) 51 HSCROLLBAR & VSCROLLBAR. The ScrollBar is a commonly used control, which enables the user to select a value by positioning it at the desired location. ➢ The Min and Max property represents the minimum and maximum value. ➢ The value property of the ScrollBar represents its current value, that may be any integer between minimum and maximum values assigned. ➢ Horizontal and vertical scroll bars are widely used in Windows applications. ➢ Scroll bars provide an intuitive way to move through a list of information and make great input devices. ➢ Both type of scroll bars are comprised of three areas that can be clicked, or dragged, to change the scroll bar value. Those areas are:
  • 52. VISUAL BASIC CONTROLS Prof. K. Adisesha (Ph. D) 52 Scroll Bar Properties: ➢ LargeChange: Increment added to or subtracted from the scroll bar Value property when the bar area is clicked. ➢ Max : The value of the horizontal scroll bar at the far right and the value of the vertical scroll bar at the bottom. Can range from -32,768 to 32,767. ➢ Min : The other extreme value - the horizontal scroll bar at the left and the vertical scroll bar at the top. Can range from -32,768 to 32,767. ➢ SmallChange : The increment added to or subtracted from the scroll bar Value property when either of the scroll arrows is clicked. ➢ Value : The current position of the scroll box (thumb) within the scroll bar. If you set this in code, Visual Basic moves the scroll box to the proper position.
  • 53. VISUAL BASIC CONTROLS Prof. K. Adisesha (Ph. D) 53 TIMER CONTROL: A Timer control is invisible at run time, and its purpose is to send a periodic pulse to the current application. You can trap this pulse by writing code in the Timer's Timer event procedure and take advantage of it to execute a task in the background or to monitor a user's actions. Timer Properties: ➢ Enabled : Used to turn the timer on and off. When on, it continues to operate until the Enabled property is set to False. ➢ Interval : Number of milliseconds between each invocation of the Timer Event. ➢ Timer Events: The timer tool only has one event, Timer. It has the form: Private Sub Timer1_Timer() Image1.Visible = True End Sub
  • 54. VISUAL BASIC CONTROLS Prof. K. Adisesha (Ph. D) 54 DRIVELISTBOX: The drive list box control allows a user to select a valid disk drive at run-time. The DriveListBox is for displaying a list of drives available in your computer. We use the box to get the current drive identification. DriveListBox control is a combobox-like control that's automatically filled with your drive's letters and volume labels. Drive List Box Properties: ➢ Drive: Contains the name of the currently selected drive. Drive List Box Events: ➢ Change: Triggered whenever the user or program changes the drive selection
  • 55. VISUAL BASIC CONTROLS Prof. K. Adisesha (Ph. D) 55 DIRLISTBOX: The DirListBox means the Directory List Box. It is for displaying a list of directories or folders in a selected drive. When you place this control into the form and run the program, you will be able to select different directories from a selected drive in your computer. ➢ The DirListBox is a special list box that displays a directory tree. The directory list box displays an ordered, hierarchical list of the user's disk directories and subdirectories. Directory List Box Properties:: ➢ Path: Contains the current directory path. Directory List Box Events: ➢ Change: Triggered when the directory selection is changed.
  • 56. VISUAL BASIC CONTROLS Prof. K. Adisesha (Ph. D) 56 FILELISTBOX: The file list box locates and lists files in the directory specified by its Path property at run-time. You may select the types of files you want to display in the file list box. ➢ The FileListBox control is a special-purpose ListBox control that displays all the files in a given directory, optionally filtering them based on their names, extensions, and attributes. File List Box Properties: ➢ FileName: Contains the currently selected file name. ➢ Pattern: Contains a string that determines which files will be displayed. It supports the use of * and ? wildcard characters. ➢ Path: Contains the current path directory. File List Box Events: ➢ DblClick: Triggered whenever a file name is double-clicked. ➢ PathChange: Triggered whenever the path changes in a file list box.
  • 57. VISUAL BASIC CONTROLS Prof. K. Adisesha (Ph. D) 57 Example:
  • 58. VISUAL BASIC CONTROLS Prof. K. Adisesha (Ph. D) 58 SHAPE CONTROL: The shape tool can create circles, ovals, squares, rectangles, and rounded squares and rectangles. Colors can be used and various fill patterns are available. ➢ It can display six basic shapes: Rectangle, Square, Oval, Circle, Rounded Rectangle, and Rounded Square. Shape Tool Properties: ➢ BackColor: Determines the background color of the shape. ➢ BackStyle: Determines whether the background is transparent or opaque. ➢ BorderColor: Determines the color of the shape's outline. ➢ BorderStyle: Determines the style of the shape's outline. ➢ BorderWidth: Determines the width of the shape border line. ➢ FillColor: Defines the interior color of the shape. ➢ FillStyle: Determines the interior pattern of a shape. ➢ Shape: Determines whether the shape is a square, rectangle, circle, or some other choice.
  • 59. VISUAL BASIC CONTROLS Prof. K. Adisesha (Ph. D) 59 ActiveX controls: ActiveX controls are COM components or objects you can insert into a application to reuse packaged functionality someone else has programmed. ➢ You can use ActiveX controls developed for Visual Basic 6.0 to add features to the Toolbox. ➢ To add ActiveX controls to the toolbox ❖ On the Tools menu, click Choose Toolbox Items. ❖ The Choose Toolbox dialog box appears. ❖ Click the COM Components tab. ❖ Select the check box next to the ActiveX control you want to use, and then click OK.
  • 60. VISUAL BASIC CONTROLS Prof. K. Adisesha (Ph. D) 60 Common Dialog control: The common dialog control provides a standard set of dialog boxes for operations such as opening and saving files, setting print options, and selecting colors and fonts. ➢ You use the common dialog control in your application by adding it to a form and setting its properties. ➢ The common dialog control allows you to display these commonly used dialog boxes: ❖ Open ❖ Save As ❖ Color ❖ Font ❖ Print
  • 61. VISUAL BASIC CONTROLS Prof. K. Adisesha (Ph. D) 61 Common Dialog control: The common dialog control provides a standard set of dialog boxes for operations such as opening and saving files, setting print options, and selecting colors and fonts.
  • 62. Discussion Prof. K. Adisesha (Ph. D) 62 Queries ? Prof. K. Adisesha 9449081542