Unit 4 Application Development On Dot Net-1

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 61

Divya S R, Assistant Professor, AES National Degree College, Gauribidanur

Unit 4: Application development on .NET

Building windows application in C#.NET

Create a project
Step1: First, you'll create a C# application project. The project type
comes with all the template files you'll need, before you've even added
anything.
1. Open Visual Studio.
2. On the start window, select Create a new project.

Step 2:

1
Divya S R, Assistant Professor, AES National Degree College, Gauribidanur

Step 3:In the Configure your new project window, type or enter
“HelloWorld” in the Project name box. Then, select Create.

Visual Studio opens your new project.


Step 4:
Create the application
After you select your C# project template and name your file, Visual
Studio opens a form for you. A form is a Windows user interface. We'll
create a "Hello World" application by adding controls to the form, and
then we'll run the app.
Add a button to the form
1. Select Toolbox to open the Toolbox fly-out window.

2
Divya S R, Assistant Professor, AES National Degree College, Gauribidanur

VB.NET Windows Forms


VB.Net programmers have made extensive use of forms to build user
interfaces. Each time you create a Windows application, Visual Studio will
display a default blank form, onto which you can drag and drop controls
from the Visual Studio Toolbox window.

The first step is to start a new project and build a form. Open your Visual
Studio and select File->New Project and select Visual Basic from the New
project dialog box and select Windows Forms Application. Enter your
project name instead of WindowsApplication1 in the bottom of dialogue
box and click OK button. The following picture shows how to create a new
Form in Visual Studio.

VB.NET windows forms


Creating a Window Forms Application by following the following steps in
Microsoft Visual Studio
File → New Project → Windows Forms Applications

3
Divya S R, Assistant Professor, AES National Degree College, Gauribidanur

4
Divya S R, Assistant Professor, AES National Degree College, Gauribidanur

If you click the icon on the top left corner, it opens the control menu,
which contains the various commands to control the form like to move
control from one place to another place, to maximize or minimize the
form or to close the form.

Form Properties
Following table lists down various important properties related to a form.
These properties can be set or read during application execution. You can
refer to Microsoft documentation for a complete list of properties
associated with a Form control

S.N Properties Description


The button that's automatically activated when
you press Enter, no matter which control has
1 AcceptButton
the focus at the time. Usually the OK button on
a form is set as AcceptButton for a form.
The button that's automatically activated when
you hit the Esc key.
2 CancelButton
Usually, the Cancel button on a form is set as
CancelButton for a form.
3 BackColor Sets the form background color.
The BorderStyle property determines the style
of the form's border and the appearance of the
form −

 None − Borderless window that can't be


resized.
 Sizable − This is default value and will be
used for resizable window that's used for
displaying regular forms.
4 BorderStyle
 Fixed3D − Window with a visible border,
"raised" relative to the main area. In this
case, windows can't be resized.
 FixedDialog − A fixed window, used to
create dialog boxes.
 FixedSingle − A fixed window with a
single line border.
 FixedToolWindow − A fixed window
with a Close button only. It looks like the

5
Divya S R, Assistant Professor, AES National Degree College, Gauribidanur

toolbar displayed by the drawing and


imaging applications.

By default, this property is True and you can set


5 ControlBox it to False to hide the icon and disable the
Control menu.
If True, allows the form to respond to mouse
6 Enabled
and keyboard events; if False, disables form.
7 Font This property specify font type, style, size
Determines whether a Help button should be
8 HelpButton
displayed in the caption box of the form.
9 Height This is the height of the Form in pixels.
By default, this property is True and you can set
10 MinimizeBox it to False to hide the Minimize button on the
title bar.
By default, this property is True and you can set
11 MaximizeBox it to False to hide the Maximize button on the
title bar.
This specifies the minimum height and width of
12 MinimumSize
the window you can minimize.
This specifies the maximum height and width of
13 MaximumSize
the window you maximize.
14 Name This is the actual name of the form.
This property determines the initial position of
the form when it's first displayed. It will have
any of the following values −

 CenterParent − The form is centered in


the area of its parent form.
 CenterScreen − The form is centered on
the monitor.
 Manual − The location and size of the
15 StartPosition
form will determine its starting position.
 WindowsDefaultBounds − The form is
positioned at the default location and size
determined by Windows.
 WindowsDefaultLocation − The form is
positioned at the Windows default location
and has the dimensions you've set at
design time.

The text, which will appear at the title bar of the


16 Text
form.

6
Divya S R, Assistant Professor, AES National Degree College, Gauribidanur

These two properties set or return the


17 Top, Left coordinates of the form's top-left corner in
pixels.
18 Width This is the width of the form in pixel.

Form Methods
The following are some of the commonly used methods of the Form class.
You can refer to Microsoft documentation for a complete list of methods
associated with forms control −

Sr.No. Method Name & Description

Activate
1
Activates the form and gives it focus.

ActivateMdiChild
2
Activates the MDI child of a form.

AddOwnedForm
3
Adds an owned form to this form.

BringToFront
4
Brings the control to the front of the z-order.

CenterToParent
5 Centers the position of the form within the bounds of the parent
form.

CenterToScreen
6
Centers the form on the current screen.

Close
7
Closes the form.

Contains
8 Retrieves a value indicating whether the specified control is a
child of the control.

Focus
9
Sets input focus to the control.

7
Divya S R, Assistant Professor, AES National Degree College, Gauribidanur

Hide
10
Conceals the control from the user.

Refresh
11 Forces the control to invalidate its client area and immediately
redraw itself and any child controls.

Scale(Size F)
12 Scales the control and all child controls by the specified scaling
factor.

ScaleControl
13
Scales the location, size, padding, and margin of a control.

ScaleCore
14
Performs scaling of the form.

Select
15
Activates the control.

SendToBack
16
Sends the control to the back of the z-order.

SetAutoScrollMargin
17
Sets the size of the auto-scroll margins.

SetDesktopBounds
18
Sets the bounds of the form in desktop coordinates.

SetDesktopLocation
19
Sets the location of the form in desktop coordinates.

SetDisplayRectLocation
20
Positions the display window to the specified value.

Show
21
Displays the control to the user.

ShowDialog
22
Shows the form as a modal dialog box.

8
Divya S R, Assistant Professor, AES National Degree College, Gauribidanur

Form Events
Following table lists down various important events related to a form. You
can refer to Microsoft documentation for a complete list of events
associated with forms control −

Sr.No. Event Description

1 Occurs when the form is activated in code


Activated
or by the user.
2 Click Occurs when the form is clicked.
3 Closed Occurs before the form is closed.
4 Closing Occurs when the form is closing.

5 Occurs when the form control is double-


DoubleClick
clicked.
6 Occurs when a drag-and-drop operation is
DragDrop
completed.
7 Enter Occurs when the form is entered.

8 Occurs when the form control receives


GotFocus
focus.
9 HelpButtonClicked Occurs when the Help button is clicked.

10 Occurs when a key is pressed while the


KeyDown
form has focus.
11 Occurs when a key is pressed while the
KeyPress
form has focus.
12 Occurs when a key is released while the
KeyUp
form has focus.
13 Occurs before a form is displayed for the
Load
first time.
14 LostFocus Occurs when the form loses focus.

15 Occurs when the mouse pointer is over the


MouseDown
form and a mouse button is pressed.
16 Occurs when the mouse pointer enters the
MouseEnter
form.
17 Occurs when the mouse pointer rests on
MouseHover
the form.
18 Occurs when the mouse pointer leaves the
MouseLeave
form.

9
Divya S R, Assistant Professor, AES National Degree College, Gauribidanur

19 Occurs when the mouse pointer is moved


MouseMove
over the form.
20 Occurs when the mouse pointer is over the
MouseUp
form and a mouse button is released.
21 Occurs when the mouse wheel moves while
MouseWheel
the control has focus.
22 Move Occurs when the form is moved.
23 Resize Occurs when the control is resized.

24 Occurs when the user or code scrolls


Scroll
through the client area.
25 Occurs whenever the form is first
Shown
displayed.
26 Occurs when the Visible property value
VisibleChanged
changes.

The general syntax is


Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
‘statements
End Sub
End Class

Example for Form


‘write a VB.NET program for sum of two numbers

Public Class Form4


Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
TextBox3.Text = Val(TextBox1.Text) + Val(TextBox2.Text)
End Sub
End Class

10
Divya S R, Assistant Professor, AES National Degree College, Gauribidanur

Controls in VB.NET
1. Label Control
In VB.NET, a label control is used to display descriptive text for the form
in control. It does not participate in user input or keyboard or mouse
events. Also, we cannot rename labels at runtime. The labels are defined
in the class System.Windows.Forms namespace.

Label Properties

Properties Description

As the name defines, an AutoSize property of label


AutoSize control is used to set or get a value if it is
automatically resized to display all its contents.

It is used to set the style of the border in the


Border Style
Windows form.

It is used to set or get the preferred width for the


PreferredWidth
Label control.

It is used to get or set the font of the text displayed


Font
on a Windows form.

PreferredHeight It is used to set the height for the Label Control.

11
Divya S R, Assistant Professor, AES National Degree College, Gauribidanur

It is used to set the alignment of text such as


TextAlign
centre, bottom, top, left, or right.

ForeColor It is used to set the color of the text.

It is used to set the name of a label in the Windows


Text
Form.

It is used to get or sets the shortcut menu


ContextMenu
associated with the Label control.

DefaultSize It is used to get the default size of the Label control.

It is used to set the image to a label in Windows


Image
Form.

It is used to set the index value to a label control


ImageIndex
displayed on the Windows form.

Label Events

Events Description
An AutoSizeChanged event occurs in the Label
AutoSizeChanged control when the value of AutoSize property is
changed.
Click event is occurring in the Label Control to
Click
perform a click.
When a user performs a double-clicked in the Label
DoubleClick
control, the DoubleClick event occurs.
It occurs when the Label Control receives focus on
GotFocus
the Window Form.
The Leave event is found when the input focus
Leave
leaves the Label Control.
It occurs when the value of Tabindex property is
TabIndexChanged
changed in the Label control.
When the control is removed from the
ControlRemoved Control.ControlCollection, a ControlRemoved event,
occurs.
It occurs when the property of TabStop is changed
TabStopChanged
in the Label Control.
A BackColorChanged event occurs in the Label
BackColorChanged control when the value of the BackColor property is
changed.

12
Divya S R, Assistant Professor, AES National Degree College, Gauribidanur

When a new control is added to the


ControlAdded Control.ControlCollection, a ControlAdded event
occurs.
A DragDrop event occurs in the Label control when
DragDrop
a drag and drop operation is completed.

Methods of the Label Control


The following are some of the commonly used methods of the Label
control:

Method Description

GetPreferredSize Retrieves the size of a rectangular area into which a


control can be fitted.

Refresh Forces the control to invalidate its client area and


immediately redraw itself and any child controls.

Select
Activates the control.

Show Displays the control to the user.

Returns a String that contains the name of the control.


ToString

The general syntax is


Control_name.Property_name=value

Example: Label1.Text = " "

Procedure for Label syntax


Public class Form1
Private Sub Label1_Click(sender As Object, e As EventArgs) Handles Label1.Click
‘statements
End Sub
End Class

13
Divya S R, Assistant Professor, AES National Degree College, Gauribidanur

Example

Public class Form1


Private Sub btn_Click(sender As Object, e As EventArgs) Handles btn.Click
Label1.Text=”Enter the first number”
Label2.Text=”Enter the second number”
Label3.Text=”Result”
Text3.Text=val(Text1.Text)+Val(Text2.Text2)
End Sub
End Class

Button Control
Button control is used to perform a click event in Windows Forms, and it
can be clicked by a mouse or by pressing Enter keys. It is used to submit
all queries of the form by clicking the submit button or transfer control to
the next form. However, we can set the buttons on the form by using
drag and drop operation.

14
Divya S R, Assistant Professor, AES National Degree College, Gauribidanur

The general syntax is


Control_name.Property_name=value

Example: button.Text = " "

Public Class Form4


Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
TextBox3.Text = Val(TextBox1.Text) + Val(TextBox2.Text)
End Sub
End Class

15
Divya S R, Assistant Professor, AES National Degree College, Gauribidanur

Procedure for Button syntax


Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
‘statements
End Sub
End Class

Button Properties

Properties Description
It is used to get or set the auto mode value through
AutoSizeMode which the button can automatically resize in the
Windows form.
It is used to set the background color of the Button
BackColor
in the Windows form.
It is used to set the background image of the
BackgroundImage
button control.
It is used to set or get the foreground color of the
ForeColor
button control.
It is used to set or gets the image on the button
Image
control that is displayed.
It is used to set the upper-left of the button
Location control's coordinates relative to the upper-left
corner in the windows form.
It is used to set the name of the button control in
Text
the windows form.
It is used to set or get a value representing whether
AllowDrop the button control can accept data that can be
dragged by the user on the form.
It is used to set or get the tab order of the button
TabIndex
control within the form.

Button Events

A BackColorChaged event is found in


BackColorChanged button control when the Background
property is changed.
A BackgoundImageChanged event is
BackgroundImageChanged found in button control when the value of
the BackgoundImage property is changed.
A Click event is found in the button
Click
control when the control is clicked.

16
Divya S R, Assistant Professor, AES National Degree College, Gauribidanur

A ControlAdded event is found in button


ControlAdded control when a new control is added to the
Control.ControlCollection.
A CursorChanged event is found in button
CursorChanged control when the value of the control is
changed.
When the user makes a double click on
DoubleClick the button, a double click event is found
in the button control.
It is found in the button control when the
TextChanged
value of the text property is changed.
The DragDrop event is found in the button
DragDrop control when the drag and drop operation
is completed in the Form.

Methods

Name Description
Retrieves the size of a rectangular area into which a
GetPreferredSize
control can be fitted.
Notifies the Button whether it is the default button so
NotifyDefault
that it can adjust its appearance accordingly.
Select Activates the control.
Returns a String containing the name of the
ToString Component, if any. This method should not be
overridden.

TextBox Control
A TextBox control is used to display, accept the text from the user as an
input, or a single line of text on a VB.NET Windows form at runtime.

17
Divya S R, Assistant Professor, AES National Degree College, Gauribidanur

The general syntax is


Control_name.Property_name=value

Example: Text1.Text = " "

Procedure for Textbox syntax


Public Class Form1
Private Sub TextBox1_TextChanged(sender As Object, e As EventArgs) Handles
TextBox1.TextChanged
‘statements
End Sub
End Class

Example

Public Class Form4


Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
TextBox3.Text = Val(TextBox1.Text) + Val(TextBox2.Text)
End Sub
End Class

Properties

Properties Description
It is used to get or set a value that indicates how
AutoCompleteMode the automatic completion works for the textbox
control.
It is used to set the font style of the text displayed
Font
on a Windows form.

18
Divya S R, Assistant Professor, AES National Degree College, Gauribidanur

It is used to set the number of lines in a TextBox


Lines
control.
It is used to get or set a value representing
CharacterCasing whether the TextBox control can modify the
character's case as they typed.
It is used to enter more than one line in a TextBox
Multiline control, by changing the Multiline property value
from False to True.
It is used to get or set a value that indicates
AcceptsReturn whether pressing the enter button in a multiline
textbox; it creates a new line of text in control.
It is used to set the password character that can
PasswordChar
be a mask in a single line of a TextBox control.
It is used to set the preferred height of the textbox
PreferredHeight
control in the window form.
It is used to display a scrollbar on a multiline
ScrollBars
textbox by setting a value for a Textbox control.
It is used to get or set the text associated with the
Text
textbox control.
The Visible property sets a value that indicates
Visible whether the textbox should be displayed on a
Windows Form.
The WordWrap properties validate whether the
multiline Textbox control automatically wraps
WordWrap
words to the beginning of the next line when
necessary.

TextBox Events

Events Description
When a textbox is clicked, a click event is
Click
called in the textbox control.
It occurs in the TextBox Control when the
CausesValidationChanged value of CauseValidation property is
changed.
It is found in the TextBox control when the
AcceptTabsChanged
property value of the AcceptTab is changed.
It is found in the TextBox Control when the
BackColorChanged
property value of the BackColor is changed.
It is found in the TextBox Control when the
BorderStyleChanged
value of the BorderStyle is changed.
It is found when the new control is added
ControlAdded
to the Control.ControlCollection.

19
Divya S R, Assistant Professor, AES National Degree College, Gauribidanur

It is found in TextBox, when the textbox


CursorChanged control is removed from the
Control.ControlCollection.
It occurs when the property of the Font is
FontChanged
changed.
It is found in TextBox control to get the
GetFocus
focus.
A MouseClick event occurs when the mouse
MouseClick
clicks the control.
It is found in a textbox control when the
MultilineChanged
value of multiline changes.

Methods

Method Description
AppendText Appends text to the current text of a text box.
Clear Clears all text from the text box control.
Copies the current selection in the text box to
Copy
the Clipboard.
Moves the current selection in the text box to
Cut
the Clipboard.
Replaces the current selection in the text box with the
Paste
contents of the Clipboard.
Sets the selected text to the specified text without
Paste(String)
clearing the undo buffer.
ResetText Resets the Text property to its default value.
ToString Returns a string that represents the TextBoxBase control.
Undo Undoes the last edit operation in the text box.

ComboBox Control
The ComboBox control is used to display more than one item in a drop-
down list. It is a combination of Listbox and Textbox in which the user
can input only one item.

20
Divya S R, Assistant Professor, AES National Degree College, Gauribidanur

The general syntax is


Control_name.Property_name=value

Example: combobox.backcolor = "blue "

Procedure for combobox syntax


Public Class Form1
Private Sub ComboBox1_SelectedIndexChanged(sender As Object, e As EventArgs)
Handles ComboBox1.SelectedIndexChanged
‘statements
End Sub
End Class

Properties
Property Description
The AllowSelection property takes the value that
AllowSelection
indicates whether the list allows selecting the list item.
It takes a value that represents how automatic
AutoCompleteMode
completion work for the ComboBox.
It takes a value that determines whether the control is
Created
created or not.
DataBinding It is used to bind the data with a ComboBox Control.
The BackColor property is used to set the background
BackColor
color of the combo box control.
It is used to get or set the data source for a ComboBox
DataSource
Control.
It is used to set the style or appearance for the
FlatStyle
ComboBox Control.

21
Divya S R, Assistant Professor, AES National Degree College, Gauribidanur

The MaxDropDownItems property is used in the combo


MaxDropDownItems box control to display the maximum number of items by
setting a value.
It is used by the user to enter maximum characters in
MaxLength
the editable area of the combo box.
It is used to set or get the selected item in the
SelectedItem
ComboBox Control.
The Sorted property is used to sort all the items in the
Sorted
ComboBox by setting the value.

ComboBox Events

Events Description
It occurs when the property of the font value is
FontChanged
changed.
When the data is bound with a combo box
Format
control, a format event is called.
It occurs when the property value of
SelectIndexChanged
SelectIndexChanged is changed.
When the user requests for help in control, the
HelpRequested
HelpRequested event is called.
It occurs when the user leaves the focus on the
Leave
ComboBox Control.
It occurs when the property of margin is changed
MarginChanged
in the ComboBox control.

Methods

slno Methods Description


Prevents the control from drawing until the
1. BeginUpdate EndUpdate method is called, while items are
added to the combo box one at a time.
Resumes drawing of a combo box, after it
2. EndUpdate
was turned off by the BeginUpdate method.
Finds the first item in the combo box that
3. FindString starts with the string specified as an
argument.
Finds the first item in the combo box that
4. FindStringExact
exactly matches the specified string.
Selects all the text in the editable area of
5. SelectAll
the combo box.

22
Divya S R, Assistant Professor, AES National Degree College, Gauribidanur

Example
Public Class Form7
Private Sub Form7_Load(sd As Object, evnt As EventArgs) Handles MyBase.Load
ComboBox1.Items.Add("Male")
ComboBox1.Items.Add("Female")
End Sub
End Class

Output

ListBox Control
The ListBox control is used to display a list of items in Windows form. It
allows the user to select one or more items from the ListBox Control.
Furthermore, we can add or design the list box by using the properties
and events window at runtime.

The general syntax is


Control_name.Property_name=value
Example: listbox.visible =true

Procedure for listbox syntax


Public Class Form1
Private Sub ListBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles
ListBox1.SelectedIndexChanged
‘statements
End Sub
End Class

23
Divya S R, Assistant Professor, AES National Degree College, Gauribidanur

List box properties

Properties
Description
Name
It takes a value that defines whether the list box
AllowSelection
allows the user to select the item from the list.
It obtains a value that determines whether the Listbox
CanSelect
control can be selected.
It is used to get or set the width of the columns in a
ColumnWidth
multicolumn Listbox.
As the name defines, a container gets the IContainer
Container
that stores the component of ListBox control.
It is used to get the collection of controls contained
Controls
within the control.
It takes a value that determines whether the control is
Created
created or not.
Width It is used to set the width of the ListBox control.
It takes a value that determines whether the ListBox
Visible control and all its child are displayed on the Windows
Form.
It is used to get or set the method that determines
SelectionMode
which items are selected in the ListBox.
It allows multiple columns of the item to be displayed
MultiColumn
by setting the True value in the Listbox.

24
Divya S R, Assistant Professor, AES National Degree College, Gauribidanur

ListBox Methods

Method Name Description


The Add() method is used to add items to an item
Add()
collection.
It is used to remove an item from an item collection.
Remove However, we can remove items using the item
name.
It is used to remove all items from the item
Clear
collection at the same time.
It is used to check whether the particular item exists
Contains
in the ListBox or not.
Show() It is used to display the control to the user.
As the name suggests, a Sort() method is used to
Sort()
arrange or sort the elements in the ListBox.
A ResetText() method is used to reset ListBox's text
ResetText()
property and set the default value.
It is used to reset the backColor property of the
ResetBackColor()
ListBox and set the default value.
It is used to notify the message of the ListBox to
OnNotifyMessage
Windows.
The GetSelected method is used to validate whether
GetSelected
the specified item is selected.

Listbox events

Sr.No. Event & Description


Click
1
Occurs when a list box is selected.
SelectedIndexChanged
2
Occurs when the SelectedIndex property of a list box is changed.
Example
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
ListBox1.Items.Add("Red horse")
ListBox1.Items.Add("Emperador")
ListBox1.Items.Add("Fundador")
ListBox1.Items.Add("Alfonso")
ListBox1.Items.Add("San Mig")
ListBox1.Items.Add("Tanduay")
End Sub
End Class

25
Divya S R, Assistant Professor, AES National Degree College, Gauribidanur

Output

CheckedListBox Control
The CheckedListBox is similar to Listbox except that it displays all
items in the list with a checkbox that allows users to check or uncheck
single or multiple items.

The general syntax is


Control_name.Property_name=value
Example: CheckedListBox.Text = " "

26
Divya S R, Assistant Professor, AES National Degree College, Gauribidanur

Procedure for checkedlist control syntax


Public Class Form1
Private Sub CheckedListBox1_SelectedIndexChanged(sender As Object, e As
EventArgs) Handles CheckedListBox1.SelectedIndexChanged
‘statements
End Sub
End Class

Properties

Properties Description
It obtains a value that determines whether the
AccessibilityObject AccessibilityObject is assigned to the
CheckedListBox control.
It gets or sets a value that tells if the accessible
AccessibleName client application has used the name of the
checkedlistbox control.
It gets a value that indicates whether the ListBox
AllowSelection
allows for the item to be selected from the list.
It gets or sets a value representing whether the
AllowScollOffset CheckedListBox control is scrolled in
ScrollControlIntoView(Control).
It is used to set the type of border around the
BorderStyle
CheckedListBox by getting or setting a value.
It is used to store a collection of checked items in
CheckedItems
the CheckedListBox.
It is used to set or get a value that indicates if the
ScrollAlwaysVisible vertical scroll bar appears in Windows Forms at all
times.
It is used to get all selected items from
SelectedItems
CheckedListBox.
It is used to get or set a value representing the
SelectionMode
items' selection mode in the CheckedListBox.
It is used to set the first visible item at the top of
TopIndex
the index in the CheckedListBox.

CheckedListBox Methods

Methods Description
It is used to unselect all the selected items in
ClearSelected()
the CheckedListBox.
It is used to create new accessibility of the
CreateAccessibilityInstance()
object in the CheckedListBox Control.

27
Divya S R, Assistant Professor, AES National Degree College, Gauribidanur

It is used to create a new instance for the


CreateItemCollection()
collected item in the list box.
It is used to destroy the handle associated
DestroyHandle()
with CheckedListBox.
It is used to validate whether the specified
Equals(Object) object is equal to the current object in the
CheckedListBox or not.
It is used to obtain the form in which
FindForm()
CheckedListBox has control.
It is used to get the text of the specified item
GetItemText(Object)
in the CheckedListBox.
It is used to get the current item type in the
GetType()
CheckedListBox.
A Show() method is used to display the
Show()
CheckedListBox Control to the user.
A Sort() method is used to sort or organize all
Sort()
the items available in CheckedListBox.

Events

Methods Description
Click Single click on it.

Example
Public Class CheckedListBox1
Private Sub CheckedListBox1_Load(sender As Object, e As EventArgs) Handles
MyBase.Load
CheckedListBox1.Items.Add("VB.NET")
CheckedListBox1.Items.Add("Java")
CheckedListBox1.Items.Add("Python")
CheckedListBox1.Items.Add("C")
CheckedListBox1.Items.Add("C#")
CheckedListBox1.Items.Add("PHP")
CheckedListBox1.Items.Add("JavaScript")
CheckedListBox1.Items.Add("Ruby Language")
CheckedListBox1.Items.Add("Android")
CheckedListBox1.Items.Add("Perl")
End Sub
End Class

28
Divya S R, Assistant Professor, AES National Degree College, Gauribidanur

Output:

RadioButton Control
The RadioButton is used to select one option from the number of
choices. If we want to select only one item from a related or group of
items in the windows forms, we can use the radio button. The
RadioButton is mutually exclusive that represents only one item is active
and the remains unchecked in the form.

29
Divya S R, Assistant Professor, AES National Degree College, Gauribidanur

The general syntax is


Control_name.Property_name=value

Example: radio.value = " true"

Procedure for radio control syntax


Public Class Form1
Private Sub RadioButton1_CheckedChanged(sender As Object, e As EventArgs)
Handles RadioButton1.CheckedChanged
‘statements
End Sub
End Class

RadioButton Properties

Property Description

It is used to set or get a value representing whether


AllowDrop
the RadioButton allows the user to drag on the form.

It is used to get or set a value that represents the


Appearance
appearance of the RadioButton.

It is used to get or set the radio control in


AutoScrollOffset
ScrollControlIntoView(Control).

AutoCheck The AutoCheck property is used to check whether the


checked value or appearance of control can be

30
Divya S R, Assistant Professor, AES National Degree College, Gauribidanur

automatically changed when the user clicked on the


RadioButton control.

The AutoSize property is used to check whether the


AutoSize radio control can be automatically resized by setting a
value in the RadioButton control.

A CanSelect property is used to validate whether a


CanSelect radio control can be selected by setting a value in the
RadioButton control.

It is used to obtain or set a value that indicates the


CheckAlign location of the check portion in the radioButton
control.

The Text property is used to set the name of the


Text
RadioButton control.

RadioButton Methods

Method Name Description

The Contains() method is used to check if the defined


Contains(Control)
control is available in the RadioButton control.

It is used to send the specified message to the


DefWndProc(Message)
Window procedure.

It is used to destroy the handle associated with the


DestroHandle()
RadioButton Control.

The Focus() method is used to set the input focus to


Focus()
the window form's RadioButton control.

It is used to return a value that represents how the


control will operate when the AutoSize property is
GetAutoSizeMode()
enabled in the RadioButton control of the Window
form.

As the name suggests, a ResetText() method is used


ResetText() to reset the property of text to its default value or
empty.

It is used to reroute an invalid field, which causes


Update()
control in the client region.

31
Divya S R, Assistant Professor, AES National Degree College, Gauribidanur

Events
the control returns a Boolean numeric value to indicate its state (0 for
deselected and 1 for selected).
Example
Public Class RadioBtn
Private Sub RadioBtn_Load(sender As Object, e As EventArgs) Handles MyBas
e.Load
RadioButton1.Text = "Male"
RadioButton2.Text = "Female"
RadioButton3.Text = "Transgender"
End Sub

Output:

CheckBox Control
The CheckBox control is a control that allows the user to select or deselect
options from the available options. When a checkbox is selected, a tick or
checkmark will appear on the Windows form.

32
Divya S R, Assistant Professor, AES National Degree College, Gauribidanur

The general syntax is


Control_name.Property_name=value
Example: checkbox.value = checked

Procedure for checkbox control syntax


Public Class Form1
Private Sub CheckBox1_CheckedChanged(sender As Object, e As EventArgs) Handles
CheckBox1.CheckedChanged
‘statements
End Sub
End Class

CheckBox Properties

There are some properties of the VB.NET CheckBox control.

Property Description

Default It is used to get the default size of the checkbox.

The AutoCheck property is used to check whether the


checked value or appearance of control can be
AutoCheck
automatically changed when the user clicked on the
CheckBox control.

It is used to set the checkmark's alignment, such as


CheckAlign
horizontal or vertical on the checkbox.

The Appearance property is used to display the appearance


Appearance
of a checkbox control by setting a value.

The CheckState property is used to verify whether the


CheckState
checkbox status is checked in the window form.

The ThreeState property is used to check whether the


ThreeState control allows one to set three check positions instead of
two by setting values.

It is used to obtain or set the flat appearance of a


FlatStyle
checkbox.

33
Divya S R, Assistant Professor, AES National Degree College, Gauribidanur

CheckBox Methods

There are some Methods of the VB.NET CheckBox control.

Method Description

The OnClick method is used to fetch the Click


OnClick
event in the CheckBox control.

It is used to call the CheckStateChanged event


OnCheckStateChanged
in the CheckBox control.

The ToString method is used to return the


ToString
current string of the CheckBox control.

When the Checked property is changed in the


OnCheckedChanged CheckBox control, the OnCheckedChanged
events occur.

It is used when it receives the OnMouseUp


OnMouseUp
event in the CheckBox control.

CheckBox Events

There are some Events of the VB.NET CheckBox control.

Event Description

The CheckedChanged event is found when the


CheckedChanged value of the checked property is changed to
CheckBox.

It occurs when the user performs a double click


DoubleClick
on the CheckBox control.

It occurs when the value of the CheckState


CheckStateChanged
property changes to the CheckBox control.

It occurs when the property of the Appearance is


AppearanceChanged
changed to the CheckBox control.

34
Divya S R, Assistant Professor, AES National Degree College, Gauribidanur

Example
Public Class Checkbxvb
Private Sub Checkbxvb_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Me.Text = "javaTpoint.com" ' Set the title name of the form
Label1.Text = "Select the fruits name"
CheckBox1.Text = "Apple"
CheckBox2.Text = "Mango"
CheckBox3.Text = "Banana"
CheckBox4.Text = "Orange"
CheckBox5.Text = "Potato"
CheckBox6.Text = "Tomato"
End Sub
End Class

35
Divya S R, Assistant Professor, AES National Degree College, Gauribidanur

PictureBox Control
PictureBox control is used to display the images on Windows Form. The
PictureBox control has an image property that allows the user to set the
image at runtime or design time.

The general syntax is


Control_name.Property_name=value
Example: picturebox.width = 100

Procedure for picturebox control syntax


Public class Form1
Private Sub picturebox_Load(sender As Object, e As EventArgs) Handles
Picture.Click
‘statements
End sub
End class

36
Divya S R, Assistant Professor, AES National Degree College, Gauribidanur

Properties of the PictureBox

There are following properties of the VB.NET PictureBox control.

Property Description

It is used to set the background color for the


BackColor
PictureBox in the window form.

It is used to set the background image of a window


BackgroundImage
form by setting or getting value in the picture box.

The ErrorImage property is used to display an


ErrorImage image if an error occurs while loading an image on
a window form.

The initial image is used to display an image on the


PictureBox when the main image is loaded onto a
InitialImage
window form by setting a value in the PictureBox
control.

It represents whether the particular image is


WaitOnLoad
synchronized or not in the PictureBox control.

It is used to set text for the picture box controls in


Text
the window form.

The image property is used to display the image on


Image
the PictureBox of a Windows form.

It is used to set the border style for the picture box


BorderStyle
in the windows form.

It is used to set or get the path or URL of the image


ImageLocation
displayed on the picture box of the window form.

It obtains a value that determines whether the


IsMirrored
picture box control is mirrored.

37
Divya S R, Assistant Professor, AES National Degree College, Gauribidanur

Methods of the PictureBox Control

Method Description

The CancelAsync method is used to cancel an


CancelAysnc()
asynchronous image load in a PictureBox control.

It is used to create handles for the picture box


CreateHandle()
controls in window form.

It is used to destroy all the handles that are


DestroyHandle()
associated with the picture box control.

The GetStyle() method is used to get values for the


GetStyle()
specified bit style in the PictureBox control.

The Load() method is used to load the specified


Load() image from the control using the ImageLocation
property.

It is used to asynchronous load the image at the


LoadAsync(String)
specified position of the picture box control.

Events of the PictureBox Control

There are some Events of the VB.NET PictureBox control.

Events Description

It occurs when the property of the


BackColorChanged backcolor is changed in the
PictureBox control.

It occurs when the property value


BackgroundImageLayoutChanged of the BackgroundImage is
changed in the PictureBox control.

It occurs when the property of the


ContextMenuChanged ContextMenu is changed in the
PictureBox control.

The resize event occurs when the


Resize
picture box control is changed.

38
Divya S R, Assistant Professor, AES National Degree College, Gauribidanur

Example
Public Class Picturebx
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
PictureBox1.Image = Image.FromFile("C:\Users\AMIT YADAV\Desktop\jtp2.png")
PictureBox1.SizeMode = PictureBoxSizeMode.StretchImage
PictureBox1.Height = 250
PictureBox1.Width = 400
Label1.Visible = False
End Sub

Private Sub Picturebx_Load(sender As Object, e As EventArgs) Handles MyBase.Load


Me.Text = "javaTpoint.com" 'Set the title name for the form
Button1.Text = "Show"
Label1.Text = "Click to display the image"
Label1.ForeColor = ForeColor.Green
End Sub
End Class

Now click on the Show button to display an image in the windows form.

39
Divya S R, Assistant Professor, AES National Degree College, Gauribidanur

ProgressBar Control
The Window ProgressBar control is used by the user to acknowledge the
progress status of some defined tasks, such as downloading a large file
from the web, copying files, installing software, calculating complex
results, and more.

The general syntax is


Control_name.Property_name=value
Example: progreebar.interval = 10

Procedure for progressbar control syntax


Public Class Form1
Private Sub ProgressBar1_Click(sender As Object, e As EventArgs) Handles
ProgressBar1.Click
‘statements
End Sub
End Class

40
Divya S R, Assistant Professor, AES National Degree College, Gauribidanur

Properties of the ProgressBar Control

There are following properties of the VB.NET ProgressBar control.

Property Description

The BackgroundImage property is used to


BackgroundImage set the background image in the progressbar
control.

It is used to determine the progress status


MarqueeAnimationSpeed
for a progress bar in milliseconds.

The padding property is used to create a


space between the edges of the progress
Padding
bar by setting the value in the progressbar
control.

It is used to get or set a value in control that


calls the PerformStep method to increase
Step
the current state of the progress bar by
adding a defined step.

It is used to set the maximum length of the


Maximum
progress bar control in the windows form.

It is used to set or get the minimum value of


Minimum the progress bar control in the windows
form.

It obtains a value representing whether the


AllowDrop progress bar control enables the user to be
dragged onto the form.

It is used to set a value that represents how


Style types the progress bar should be displayed
on the Windows Form.

41
Divya S R, Assistant Professor, AES National Degree College, Gauribidanur

Methods of the ProgressBar Control

Event Description

The ForeColor method is used to reset the forecolor to its


ForeColor
default value.

The ToString method is used to display the progress bar


ToString
control by returning the string.

It is used to increase the current state of the progress bar


Increment
control by defining the specified time.

The PerformStep method is used to increase the progress


PerformStep bar by setting the step specified in the ProgressBar
property.

Events of the ProgressBar Control

Events Description

The Leave event occurs when the focus


Leave
leaves the progress bar control.

A MouseClick event occurred when the


MouseClick user clicked on the progress bar control
by the mouse.

When the background property changes to


the progress bar control, the
BackgroundImageChanged
BackgroundImageChanged event
changes.

It occurs when the property of the text is


TextChanged
changed in the progress bar control.

It occurs when the padding property is


PaddingChanged
changed in the progress bar control.

42
Divya S R, Assistant Professor, AES National Degree College, Gauribidanur

Example
Public Class Progressbr
Private Sub Progressbr_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Me.Text = "javaTpoint.com"
Button1.Text = "Show"
Label1.Text = "Click to display the progress status of the ProgressBar"
Label1.ForeColor = ForeColor.Green
ProgressBar1.Visible = False

'create a progress bars


Dim Progressbr2 As ProgressBar = New ProgressBar()

'set the progressbar position


Progressbr2.Location = New Point(60, 70)
'set the values for Progressbr2
Progressbr2.Minimum = 0
Progressbr2.Maximum = 500
Progressbr2.Value = 470

'add the progress bar status to the form.


Me.Controls.Add(Progressbr2)

End Sub

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click


ProgressBar1.Visible = True

Dim i As Integer
ProgressBar1.Minimum = 0
ProgressBar1.Maximum = 300

For i = 0 To 300 Step 1


ProgressBar1.Value = i
If i > ProgressBar1.Maximum Then
i = ProgressBar1.Maximum
End If
Next
MsgBox("Successfully Completed")
End Sub
End Class

Output

43
Divya S R, Assistant Professor, AES National Degree College, Gauribidanur

Click on the Show button to display the progress status at run time in
Windows Form.

And when the progress status reaches the progress bar's maximum value,
it displays the following message.

ScrollBars Control
A ScrollBar control is used to create and display vertical and horizontal
scroll bars on the Windows form. It is used when we have large
information in a form, and we are unable to see all the data.
Therefore, we used VB.NET ScrollBar control. Generally, ScrollBar is of
two types: HScrollBar for displaying scroll bars and VScrollBar for
displaying Vertical Scroll bars.

44
Divya S R, Assistant Professor, AES National Degree College, Gauribidanur

The general syntax for Vscrollbar and Hscrollbar is


Public Class Form1
Private Sub VScrollBar1_Scroll(sender As Object, e As ScrollEventArgs) Handles
VScrollBar1.Scroll
‘statements
End Sub
End Class

Properties of the ScrollBar Control

There are following properties of the VB.NET ScrollBar control.

Property Description
The BackColor property is used to set the back color
BackColor
of the scroll bar.
It is used to set or get the maximum value of the
Maximum
Scroll Bar control. By default, it is 100.
It is used to get or set the minimum value of the
Minimum
Scroll bar control. By default, it is 0.
It is used to obtain or set a value that will be added
SmallChange or subtracted from the property of the scroll bar
control when the scroll bar is moved a short distance.
As the name suggests, the AutoSize property is used
to get or set a value representing whether the scroll
AutoSize
bar can be resized automatically or not with its
contents.

45
Divya S R, Assistant Professor, AES National Degree College, Gauribidanur

It is used to obtain or set a value that will be added


LargeChange or subtracted from the property of the scroll bar
control when the scroll bar is moved a large distance.
It is used to obtain or set a value in a scroll bar
Value
control that indicates a scroll box's current position.
It is used to get the default input method Editor (IME)
DefaultImeMode that are supported by ScrollBar controls in the
Windows Form.

Methods of the ScrollBar Control

Method Description
It is used to update the ScrollBar
control using the Minimum, maximum,
UpdateScrollInfo
and the value of LargeChange
properties.
It is used to raise the Scroll event in the
OnScroll(ScrollEventArgs)
ScrollBar Control.
It is used to raise the EnabledChanged
OnEnabledChanged
event in the ScrollBar control.
It is used to activate or start the
Select
ScrollBar control.
It is used to raise the ValueChanged
OnValueChanged(EventArgs)
event in the ScrollBar control.

Events of the ScrollBar Control

Event Description
The AutoSizeChanged event is found in the
AutoSizeChanged ScrollBar control when the value of the AutoSize
property changes.
The Scroll event is found when the Scroll control is
Scroll
moved.
It occurs in the ScrollBar control when the value of
TextChangedEvent
the text property changes.
A ValueChanged event occurs when the property of
ValueChanged the value is changed programmatically or by a
scroll event in the Scrollbar Control.

46
Divya S R, Assistant Professor, AES National Degree College, Gauribidanur

Example
Public Class ScrollBar
Private Sub ScrollBar_Load(sender As Object, e As EventArgs) Handles MyBase.Load

Me.Text = "javatpoint.com" 'Set the title for a Windows Form


Label1.Text = "Use of ScrollBar in Windows Form"
Label1.ForeColor = Color.Blue
Me.AutoScroll = True
Me.VScrollBar1.Minimum = 0
Me.VScrollBar1.Maximum = 100
Me.VScrollBar1.Value = 0
Me.VScrollBar1.BackColor = Color.Blue
Me.HScrollBar1.Minimum = 0
Me.HScrollBar1.Maximum = 100
Me.HScrollBar1.Value = 35
End Sub
End Class

Group Box Control


GroupBox is a container of other control. It displays a frame
around a group of controls. When you move the GroupBox control, all
of its contained will also move.

47
Divya S R, Assistant Professor, AES National Degree College, Gauribidanur

The general syntax is


Public Class Form1
Private Sub GroupBox1_Enter(sender As Object, e As EventArgs) Handles
GroupBox1.Enter
‘statements
End Sub
End Class

GroupBox properties

48
Divya S R, Assistant Professor, AES National Degree College, Gauribidanur

Events

Timer Control
The timer control is a looping control used to repeat any task in a given
time interval. It is an important control used in Client-side and Server-
side programming, also in Windows Services.
Furthermore, if we want to execute an application after a specific amount
of time, we can use the Timer Control. Once the timer is enabled, it
generates a tick event handler to perform any defined task in its time
interval property. It starts when the start() method of timer control is
called, and it repeats the defined task continuously until the timer stops.

49
Divya S R, Assistant Professor, AES National Degree College, Gauribidanur

The general syntax is


Public Class Form1
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
‘statements
End Sub
End Class

Timer Control Properties

There are following properties of the VB.NET Timer control.

Properties Description
The Name property is used to set the name of the
Name
control.
The Enables property is used to enable or disable the
Enabled
timer control. By default, it is True.
An Interval property is used to set or obtain the
iteration interval in milliseconds to raise the timer
Interval
control's elapsed event. According to the interval, a
timer repeats the task.
The AutoReset property is used to obtain or set a
AutoReset Boolean value that determines whether the timer
raises the elapsed event only once.
Events property are used to get the list of event
Events
handler that is associated with Event Component.
It is used to get a value that represents whether the
CanRaiseEvents
component can raise an event.

Events of Timer Control

50
Divya S R, Assistant Professor, AES National Degree College, Gauribidanur

Events Description
When control or component is terminated by calling the
Disposed
Dispose method, a Dispose event occurs.
When the interval elapses in timer control, the Elapsed event
Elapsed
has occurred.
A tick event is used to repeat the task according to the time
set in the Interval property. It is the default event of a timer
Tick
control that repeats the task between the Start() and Stop()
methods.

Methods of Timer Control

Methods Description
The BeginInt() method is used to start run time
BeginInt() initialization of a timer control used on a form or by
another component.
The Dispose() method is used to free all resources
Dispose()
used by the Timer Control or component.
It is used to release all resources used by the
Dispose(Boolean)
current Timer control.
The Close() method is used to release the resource
Close()
used by the Timer Control.
The Start() method is used to begin the Timer
Start() control's elapsed event by setting the Enabled
property to true.
The EndInt() method is used to end the run time
EndInt() initialization of timer control that is used on a form
or by another component.
The Stop() method is used to stop the timer
Stop() control's elapsed event by setting Enabled property
to false.

Numeric-up-down
 The NumericUpDown control looks like a combination of a text box
and a pair of arrows that the user can click to adjust a value.
 The control displays and sets a single numeric value from a list of
fixed numeric-value choices.

51
Divya S R, Assistant Professor, AES National Degree College, Gauribidanur

 The user can increase and decrease the number by clicking the up
and down arrows, by pressing the UP and DOWN ARROW keys, or
by typing a number in the text box part of the control.

 Clicking the UP ARROW key moves the number toward the


maximum; clicking the DOWN ARROW key moves the number
toward the minimum.

The general syntax is

Public Class Form1


Private Sub NumericUpDown1_ValueChanged(sender As Object, e As EventArgs) Handles
NumericUpDown1.ValueChanged
‘statements
End Sub
End Class

Example
Public Class Form12

Private Sub NumericUpDown1_ValueChanged(ByVal sender As System.Object, ByVal e As

System.EventArgs) Handles NumericUpDown1.ValueChanged


'NumericUpDown value will show in TextBox
TextBox1.Text = NumericUpDown1.Value
End Sub
End Class

52
Divya S R, Assistant Professor, AES National Degree College, Gauribidanur

Properties
NumericUpDown Control Properties
DecimalPlaces: Gets or sets the number of decimal places to display in
NumericUpDown Control.
UpDownAlign: Set positions the arrow buttons on the left or the right
side of the NumericUpDown. Default value is Right.
Increment: Gets or sets the value to increment or decrement the
NumericUpDown.

Methods
UpButton and DownButton.

Events

53
Divya S R, Assistant Professor, AES National Degree College, Gauribidanur

Track bar
The Windows Forms TrackBar control (also sometimes called a "slider"
control) is used for navigating through a large amount of
information or for visually adjusting a numeric setting. The
TrackBar control has two parts: the thumb, also known as a slider, and
the tick marks. The thumb is the part that can be adjusted.

The general syntax Track bar


Public Class Form1
Private Sub TrackBar1_Scroll(sender As Object, e As EventArgs) Handles
TrackBar1.Scroll
‘statements
End Sub
End Class

54
Divya S R, Assistant Professor, AES National Degree College, Gauribidanur

Properties of TrackBar control:-

55
Divya S R, Assistant Professor, AES National Degree College, Gauribidanur

Events of Trackbar

Methods for Trackbar


SetRange Sets the Minimum and Maximum properties of the track bar.

56
Divya S R, Assistant Professor, AES National Degree College, Gauribidanur

Functions in VB.NET
 In VB.NET, the function is a separate group of codes that are used
to perform a specific task when the defined function is called in a
program. After the execution of a function, control transfer to the
main() method for further execution.
 It returns a value. In VB.NET, we can create more than one function
in a program to perform various functionalities.
 The function is also useful to code reusability by reducing the
duplicity of the code.
For example, if we need to use the same functionality at multiple
places in a program, we can simply create a function and call it
whenever required.

Defining a Function
The syntax to define a function is:
[Access_specifier ] Function Function_Name [ (ParameterList) ] As
Return_Type
[ Block of Statement ]
Return return_val
End Function

Where,
 Access_Specifier: It defines the access level of the function such
as public, private, or friend, Protected function to access the
method.
 Function_Name: The function_name indicate the name of the
function that should be unique.
 ParameterList: It defines the list of the parameters to send or
retrieve data from a method.
 Return_Type: It defines the data type of the variable that returns
by the function.

57
Divya S R, Assistant Professor, AES National Degree College, Gauribidanur

Example
Public Function add() As Integer
' Statement to be executed
End Function

Private Function GetData( ByVal username As String) As String


' Statement to be executed
End Function

Public Function GetData( ByVal username As String, ByVal userId As Int


eger) As String
' Statement to be executed
End Function

Example
Function FindMax(ByVal num1 As Integer, ByVal num2 As Integer) As Integer

Dim result As Integer

If (num1 > num2) Then


result = num1
Else
result = num2
End If
FindMax = result

End Function

Function Returning a Value


In VB.Net, a function can return a value to the calling code in two ways −
 By using the return statement
 By assigning the value to the function name

58
Divya S R, Assistant Professor, AES National Degree College, Gauribidanur

Subroutines VB.NET
A Sub procedure is a separate set of codes that are used in VB.NET
programming to execute a specific task, and it does not return any
values. The Sub procedure is enclosed by the Sub and End Sub
statement.
The Sub procedure is similar to the function procedure for executing a
specific task except that it does not return any value, while the function
procedure returns a value.

Defining the Sub procedure


Following is the syntax of the Sub procedure:

[Access_Specifier] Sub Sub_name [ (parameterList) ]


[ Block of Statement to be executed ]
End Sub

Where,
 Access_Specifier: It defines the access level of the procedure such
as public, private or friend, Protected, etc. and information about
the overloading, overriding, shadowing to access the method.
 Sub_name: The Sub_name indicates the name of the Sub that
should be unique.
 ParameterList: It defines the list of the parameters to send or
retrieve data from a method.
Example
Public Sub getDetails()
' Statement to be executed
End Sub

Private Sub GetData( ByVal username As String) As String


' Statement to be executed
End Sub

59
Divya S R, Assistant Professor, AES National Degree College, Gauribidanur

Public Function GetData1( ByRef username As String, ByRef userId


As Integer)
' Statement to be executed
End Sub

Database applications
What is Data?
Data is a collection of a distinct small unit of information. It can be used
in a variety of forms like text, numbers, media, bytes, etc. it can be
stored in pieces of paper or electronic memory, etc.

What is Database?
A database is an organized collection of data, so that it can be easily
accessed and managed.

You can organize data into tables, rows, columns, and index it to make it
easier to find relevant information.

Database handlers create a database in such a way that only one set of
software program provides access of data to all the users.

The main purpose of the database is to operate a large amount of


information by storing, retrieving, and managing data.

There are many dynamic websites on the World Wide Web nowadays
which are handled through databases. For example, a model that checks
the availability of rooms in a hotel. It is an example of a dynamic website
that uses a database.

There are many databases available like MySQL, Sybase, Oracle,


MongoDB, Informix, PostgreSQL, SQL Server, etc.

60
Divya S R, Assistant Professor, AES National Degree College, Gauribidanur

Modern databases are managed by the database management system


(DBMS).

SQL or Structured Query Language is used to operate on the data stored


in a database. SQL depends on relational algebra and tuple relational
calculus.

Five database applications are


Some examples of such applications include:
 Online encyclopaedias (Wikipedia)
 Social media websites (Facebook)
 CRM systems (Salesforce)
 Email systems (Gmail)
 E-commerce websites (Amazon)

61

You might also like