0% found this document useful (0 votes)
56 views36 pages

LABfile-Jhanvi Pathak

The program uses a timer control that is started and stopped via buttons. When the timer ticks, it increments a textbox counter and alternates the label color between blueviolet and green, creating a timer watch effect. The timer interval is set to 600 milliseconds so the label and counter will update approximately every 0.6 seconds.

Uploaded by

JHanvi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
56 views36 pages

LABfile-Jhanvi Pathak

The program uses a timer control that is started and stopped via buttons. When the timer ticks, it increments a textbox counter and alternates the label color between blueviolet and green, creating a timer watch effect. The timer interval is set to 600 milliseconds so the label and counter will update approximately every 0.6 seconds.

Uploaded by

JHanvi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 36

Delhi Technical Campus

Greater Noida

Front End Design Tool VB.Net


LAB
[BCA-251]
NAME: Jhanvi Pathak
ENROLLMENT NO:

1|Page
INDEX
S.No Lab Assignment Page No Date of Teacher’s
Execution Signature
1 Write a program to construct 4-6 23-Aug-21
a calculator
2 Write a program to show the 7 06-Sep-21
concept of Keyword
Constant
3 Write a program to show the 8 06-Sep-21
concept of Keyword Enum
4 Write a program to check if 9 13-Sep-21
else condition
5 Write a program to check 10-11 13-Sep-21
else if condition
6 Write a program to show the 12 20-Sep-21
execution of for loop
7 Write a program to show the 13 20-Sep-21
execution of do while loop
8 Write a program to find out 12 05-Oct-21
the area of circle from given
radius with const keyword
9 Write a program to show the 15-17 11-Oct-21
use of Timer and create
Timer Watch
10 Write a program to show the 18 18-Oct-21
use of tree view control and
add nodes in it.
11 Write a program to show the 19-21 25-Oct-21
use of ComboBox and
ListBox controls
12 Write a program to add the 22 08-Nov-21
two given numbers
13 Write a program to subtract 23 08-Nov-21
the two given numbers
14 Write a program to multiply 24 08-Nov-21
the two given numbers
15 Write a program to divide 25 08-Nov-21
the two given numbers
16 Write a program to show the 26 22-Nov-21
use of open file dialog box
17 Write a program to show the 27 22-Nov-21
use of colour dialog box
18 Write a program to show the 28 22-Nov-21
use of font dialog box
19 Write a program to show the 29-30 22-Nov-21
use of save file dialog box
20 Write a program to show the 31 29-Nov-21

2|Page
concept of function
overloading
21 Write a program to show the 32 29-Nov-21
concept of inheritance

22 Write a program to show the 33 29-Nov-21


concept of overriding
23 Show all the steps of 34-36 07-Dec-21
connection with database

3|Page
PROGRAM-1
Write a program to construct a calculator
SOURCE CODE:
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
If RadioButton1.Checked = True Then
TextBox3.Text = Val(TextBox1.Text) + Val(TextBox2.Text)
ElseIf RadioButton2.Checked = True Then
TextBox3.Text = Val(TextBox1.Text) - Val(TextBox2.Text)
ElseIf RadioButton3.Checked = True Then
TextBox3.Text = Val(TextBox1.Text) * Val(TextBox2.Text)
ElseIf RadioButton4.Checked = True Then
TextBox3.Text = Val(TextBox1.Text) / Val(TextBox2.Text)
ElseIf RadioButton5.Checked = True Then
TextBox3.Text = Val(TextBox1.Text) ^ Val(TextBox2.Text)
ElseIf RadioButton6.Checked = True Then
TextBox3.Text = Val(Math.Sqrt(TextBox1.Text))
Else
MsgBox("No operation selected!", MsgBoxStyle.Exclamation)
End If
End Sub

End Class

OUTPUT

4|Page
5|Page
6|Page
PROGRAM-2
Write a program to show the concept of Keyword Constant
Code
Class areaofsquare
Public Shared Sub Main()
Const a = 20
Dim area = a * a
Console.WriteLine($"area of square is {area} ")
Console.ReadKey()

End Sub
End Class

Output

7|Page
PROGRAM-3
Write a program to show the concept of Keyword Enum

Code
Module Enum_Data
Enum Fruits
' List of enumerated data
Banana
Mango
Orange = 6
Pineapple
Apple

End Enum
Sub Main()

Console.WriteLine(" Fruit code of Banana " & Fruits.Banana) 'call with enumeration and items name
Console.WriteLine(" Fruit code of orange " & Fruits.Mango)
Console.WriteLine(" Fruit code of oranges " & Fruits.Orange)
Console.WriteLine(" Fruit code of pineapple " & Fruits.Pineapple)
Console.WriteLine(" Fruit code of apple " & Fruits.Apple)

Console.WriteLine(" Press any key to exit...")


Console.ReadKey()
End Sub
End Module

Output

8|Page
PROGRAM-4
Write a program to check if else condition
CODE
Module decisions
Sub Main()
'local variable definition '
Dim a As Integer
Console.Write("ENTER THE NUMBER : ")
a = Integer.Parse(Console.ReadLine())

' check the boolean condition using if statement


If (a < 20) Then
' if condition is true then print the following
Console.Write(Environment.NewLine)
Console.WriteLine("a is less than 20")
Else
' if condition is false then print the following
Console.Write(Environment.NewLine)
Console.WriteLine("a is not less than 20")
End If
Console.Write(Environment.NewLine)
Console.WriteLine("value of a is : {0}", a)
Console.ReadLine()
End Sub
End Module

OUTPUT

9|Page
PROGRAM-5
Write a program to check else if condition
Code
Module decisions
Sub Main()
'local variable definition '
Dim A As Integer
Console.Write("ENTER THE NUMBER :10 or 20 ")
A = Integer.Parse(Console.ReadLine())
' check the boolean condition '
If (A = 10) Then
' if condition is true then print the following '
Console.WriteLine("Value of is 10") '
ElseIf (A = 20) Then
'if else if condition is true '
Console.WriteLine("Value of a is 20") '
Else
'if none of the conditions is true
Console.WriteLine("None of the values is matching")
End If
End Sub
End Module

OUTPUT

10 | P a g e
11 | P a g e
PROGRAM-6
Write a program to show the execution of for loop
Code
Module loops

Sub Main()
Dim a, b, t As Byte
Console.Write("ENTER THE NUMBER TO GET ITS TABLE : ")
b = Integer.Parse(Console.ReadLine())
Console.Write(Environment.NewLine)
Console.WriteLine("Table is : ")
Console.Write(Environment.NewLine)
For a = 1 To 10
t=b*a
Console.WriteLine(t)
Next
Console.WriteLine("that is the table")

End Sub
End Module

Output

12 | P a g e
PROGRAM-7
Write a program to show the execution of do while loop
CODE:
Module loops
Sub Main()
Dim a = 1, b, t As Integer
Console.Write("ENTER THE NUMBER TO GET ITS TABLE : ")
b = Integer.Parse(Console.ReadLine())
Console.Write(Environment.NewLine)
Console.WriteLine("Table OF {0} IS : ", b)
Console.Write(Environment.NewLine)
Do
t=b*a
Console.WriteLine(t)
a=a+1

Loop While (a <= 10)


Console.Write(Environment.NewLine)
Console.WriteLine(" here your table ")
End Sub
End Module
OUTPUT:

13 | P a g e
PROGRAM-8
Write a program to find out the area of circle from given radius with const
keyword

CODE:
Module Module1

Sub Main()

Dim radius As Single = 1


Dim area As Single = 1
Const Pi = 3.1416
Console.Write(“ENTER RADIUS FOR AREA : “)
radius = Single.Parse(Console.ReadLine())
area = Pi * radius * radius
Console.WriteLine(“AREA FROM THE GIVEN RADIUS IS : {0}”, area)

End Sub

End Module
OUTPUT:

14 | P a g e
PROGRAM-9
Q1. Write a program to show the use of Timer and create Timer Watch.

CODE:

START BUTTON
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Timer1.Enabled = True
Timer1.Start() 'Start the timer

End Sub
STOP BUTTON
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Timer1.Stop() ' Stop the timer
End Sub

ON FORM 1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Me.Text = "time form"
Label1.Text = "Timer Control"
TextBox1.Text = 1
Timer1.Enabled = True

Button1.Text = "Start"
Button1.BackColor = Color.Blue
Button1.ForeColor = Color.AliceBlue
Button2.Text = "Stop"
Button2.BackColor = Color.Green
Button2.ForeColor = Color.AliceBlue

15 | P a g e
Timer1.Start()
Timer1.Interval = 600

End Sub
ON TIMER 1
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
If Label1.ForeColor = Color.Green Then
Label1.ForeColor = Color.BlueViolet

ElseIf Label1.ForeColor = Color.Green Then


Label1.ForeColor = Color.BlueViolet
End If
TextBox1.Text = TextBox1.Text + 1

End Sub

OUTPUT:

START

16 | P a g e
STOP

17 | P a g e
PROGRAM-10
Write a program to show the use of tree view control and add nodes in it.
CODE:
Public Class Form1

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

Dim A As String = InputBox("Enter Data")

If (TreeView1.SelectedNode) Is Nothing Then

TreeView1.Nodes.Add(A, A, 0, 1)

Else

TreeView1.SelectedNode.Nodes.Add(A, A, 0, 1)

End If

End Sub

Private Sub TreeView1_AfterSelect(sender As Object, As e TreeViewEventArgs) Handles


TreeView1.AfterSelect()

End Sub

End Class

CODE:

18 | P a g e
PROGRAM-11
Write a program to show the use of ComboBox and ListBox controls.
CODE:
Public Class Form1

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


ComboBox1.Items.Add("books")
ComboBox1.Items.Add("games")

Label1.Text = ListBox1.SelectedItem

End Sub

Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click


ComboBox1.Sorted = True
ListBox1.Sorted = True

End Sub

Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click


ComboBox1.Items.Clear()
ListBox1.Items.Clear()

End Sub

Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click


ComboBox1.Items.Remove(ComboBox1.SelectedItem)
ListBox1.Items.Remove(ListBox1.SelectedItem)

End Sub

Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click


Label1.Text = ComboBox1.Items.Count
End Sub

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


ListBox1.Items.Add("BCA")
ListBox1.Items.Add("MCA")
ListBox1.Items.Add("BBA")
ListBox1.Items.Add("MBA")

End Sub

Private Sub Button6_Click(sender As Object, e As EventArgs) Handles Button6.Click


ListBox1.Items.Add(ComboBox1.SelectedItem)
End Sub
End Class

19 | P a g e
OUTPUT:

ADD

COUNT

20 | P a g e
ADD ITEMS(LABEL)

CLEAR

REMOVE
PROGRAM-12
Write a program to add the two given numbers

21 | P a g e
CODE
Module Module1

Sub Main()
Dim num1, num2, sum As Integer

Console.Write(" ENTER FIRST NUMBER : ")


num1 = Convert.ToInt32(Console.ReadLine())
Console.Write(" ENTER SECOND NUMBER : ")
num2 = Convert.ToInt32(Console.ReadLine())
sum = num1 + num2
Console.Write(Environment.NewLine & " Addition will be : " & sum)
Console.ReadLine()
End Sub

End Module

CODE:

22 | P a g e
PROGRAM-13
Write a program to subtract the two given numbers
CODE:
Module Module1
Sub Main()
Dim num1, num2, Subtraction As Integer

Console.Write(" ENTER FIRST NUMBER : ")


num1 = Convert.ToInt32(Console.ReadLine())
Console.Write(" ENTER SECOND NUMBER : ")
num2 = Convert.ToInt32(Console.ReadLine())
Subtraction = num1 - num2
Console.Write(Environment.NewLine & " Subtraction will be : " & Subtraction)
Console.ReadLine()
End Sub

End Module

OUTPUT:

23 | P a g e
PROGRAM-14
Write a program to multiply the two given numbers
CODE:
Module Module1
Sub Main()
Dim num1, num2, multiply As Integer

Console.Write(" ENTER FIRST NUMBER : ")


num1 = Convert.ToInt32(Console.ReadLine())
Console.Write(" ENTER SECOND NUMBER : ")
num2 = Convert.ToInt32(Console.ReadLine())
multiply = num1 * num2
Console.Write(Environment.NewLine & " Answer will be : " & multiply)
Console.ReadLine()
End Sub

End Module

OUTPUT:

24 | P a g e
PROGRAM-15
Write a program to divide the two given numbers
CODE:
Module Module1
Sub Main()
Dim num1, num2, divide As Integer

Console.Write(" ENTER FIRST NUMBER : ")


num1 = Convert.ToInt32(Console.ReadLine())
Console.Write(" ENTER SECOND NUMBER : ")
num2 = Convert.ToInt32(Console.ReadLine())
divide = num1 / num2
Console.Write(Environment.NewLine & " Answer will be : " & divide)
Console.ReadLine()
End Sub

End Module

OUTPUT:

25 | P a g e
PROGRAM-16
Write a program to show the use of open file dialog box
CODE :
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
If OpenFileDialog1.ShowDialog <> Windows.Forms.DialogResult.Cancel Then
PictureBox1.Image = Image.FromFile(OpenFileDialog1.FileName)
End If

End Sub
End Class

OUTPUT

26 | P a g e
PROGRAM-17
Write a program to show the use of colour dialog box
CODE;:
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
If ColorDialog1.ShowDialog <> Windows.Forms.DialogResult.Cancel Then
Label1.ForeColor = ColorDialog1.Color
End If

End Sub
End Class

OUTPUT :

27 | P a g e
PROGRAM-18
Write a program to show the use of font dialog box
Code;
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
If FontDialog1.ShowDialog <> Windows.Forms.DialogResult.Cancel Then
RichTextBox1.ForeColor = FontDialog1.Color
RichTextBox1.Font = FontDialog1.Font
End If

End Sub
End Class

OUTPUT:

28 | P a g e
PROGRAM-19
Write a program to show the use of save file dialog box

CODE :

Public Class Form1


Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
SaveFileDialog1.Filter = “TXT Files (*.txt*)|*.txt”
If SaveFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
My.Computer.FileSystem.WriteAllText(SaveFileDialog1.FileName, RichTextBox1.Text, True)
End If

End Sub

OUTPUT:

29 | P a g e
30 | P a g e
PROGRAM-20
Write a program to show the concept of function overloading
CODE:
Imports System
Class adder
Public Overloads Sub Add(A As String, B As String)
Console.WriteLine("Adding Strings: " + A + B)
End Sub

Shared Sub Main()


Dim AdderObj As adder
AdderObj = New adder
AdderObj.Add(20, 50)
AdderObj.Add("hello", " I am Jhanvi")
End Sub
End Class

OUTPUT:

31 | P a g e
PROGRAM-21
Write a program to show the concept of inheritance
CODE:
Imports System
Class Human
Public Sub Talk()
Console.WriteLine("Talking")
End Sub
End Class
Class Programmer
Inherits Human

Public Sub StealCode()


Console.WriteLine("Stealing code")
End Sub
End Class
Class MainClass

Shared Sub Main()


Dim Rohan As Programmer
Rohan = New Programmer

Rohan.Talk()
Rohan.StealCode()
End Sub
End Class

OUTPUT:

32 | P a g e
PROGRAM-22
Write a program to show the concept of overriding
CODE:
Imports System

Class Human
Public Overridable Sub Speak()
Console.WriteLine("Speaking")
End Sub
Class Indian
Inherits Human

Public Overrides Sub Speak()


Console.WriteLine("Speaking Hindi")

End Sub
End Class
Class MainClass

Shared Sub Main()

Dim Johan As Human


Johan = New Human

Dim Tony As Indian


Tony = New Indian

Johan.Speak()

Tony.Speak()
End Sub
End Class
End Class

OUTPUT:

33 | P a g e
PROGRAM-23
Show all the steps of connection with database
OUTPUT:

34 | P a g e
35 | P a g e
36 | P a g e

You might also like