You are on page 1of 103

AN

ASSIGNMENT
ON
DOT NET TECHNOLOGY
BACHELOR OF COMPUTER APPLICATION
From
Pt. Ravishankar shukla University Raipur (C.G.)
Final Year
Year: 2022-2023

Guided by Submitted by
Mrs. Minal Chaphekar Ashish Sahu
Asst. Prof. (Comp. Science Dept.) CLASS-BCA3

Submitted to
Pragati College Raipur (C.G)
Pt. Ravishankar Shukla University Raipur (C.G)
ACKNOWLEDGEMENT
No work can be completed successfully without the help, inspiration
an encouragement by the elders and seniors. So my heartily thanks
to all of them who helped me while preparing this assignment. I
would begin by thanking to my parents who provided me the
required support for completing this job.
I Acknowledgement and thanks for the help
received form Mrs. Minal Chaphekar our “ASSIGNMENT
INCHARGE” and classmates who guided me to complete this
assignment.

1
CERTIFICATE OF APPROVAL

This is to certify that the assignment work on “Dot Net Teachnoloy”


is carried out by Ashish Sahu a student of BCA-3 YEAR at PRAGATI
COLLEGE is hereby approved as credible work in the discipline of
Dot Net for the award of degree of BCA-3 YEAR during the year
2021-2022 from
PT. RAVISHANKAR SHUKLA UNIVERSITY,RAIPUR(C.G).

Mrs. Minal Chaplekar


Asst. Prof. (Comp. Science Dept.)
2
PRAGATI COLLEGE, RAIPUR (C.G)

CERTIFICATE OF EVALUATION

This is to certify that the project work entitled is “Dot Net” carried
out by Ashish Sahu a student of “BCA-3 YEAR” at PRAGATI
COLLEGE, after proper evaluation and examination, is hereby
approved as a satisfactory manner for its acceptance as a requisite
for the award of degree of “BCA-3 YEAR” during the year 2022-
2023 form PT. RAVISHANKAR SHUKLA UNIVERSITY,
RAIPUR(C.G.).

3
Internal Examiner External Examiner

4
IND
EX
S. Name of Program Page Rema
No. no. rk

1 Write a program to find maximum between three numbers. 1-2

2 Write a program to check whether a number is 3


negative,positive
or zero
3 Write a program to check whether a year is leap year or not. 4

4 Write a program to check whether a character is alphabet or 5


not.
5 Write a program to find all roots of a quadratic equation. 6-7

6 Design an application to input marks of five subjects physics, 8-10


chemistry, biology, mathematics and computer. Calculate
percentage and grade according to following:
Percentage>=90% : grade A
Percentage>=80% : grade B
Percentage>=70% : grade C
Percentage>=60% : grade C
Percentage>=40% : grade E
Percentage<40% : grade F

7 Design an application to input basic salary of an employee and 11-12


Gross salary according to following:
Basic Salary <=10000 :HRA=20%,DA=80%
Basic Salary <=20000 :HRA=25%,DA=90%
Basic Salary >10000 :HRA=30%,DA=95%
8 Design an application which is similar to login from 13-14

9 WAP using checkbox for the following font effects. 15-17


Bold
Italic
Underline
Increase font size
Decrease font size
5
Font color

10 Design the form that calculate Sum, Multiplication, Division 18-19


and
Subtraction of two number.
11 Design Simple calculator. 20-23

12 Design the form to input radius of a circle and find its 24-25
circumference and area.
13 Design the form to input length in centimeter and convert it 26
into
meter.
14 Design the form to input temperature in Celsius and convert it 27
into Fahrenheit.
15 Design the form to input Principal amount, Time, Rate and 28-29
calculate Simple Interest and compound interest show result
information in msgbox.
16 Design the form and write a program to sort array element in 30-31
ascending order
17 Design the form and write a program to insert an element in an 32-33
array.
18 Design the form and write a program to delete an element from 34-35
an array at specified position.
19 Design the form and write a program to print all unique 36-37
elements in the array.
20 Design a form to check whether a number is PRIME or NOT 38-39
using input box and msgbox.
21 Write a program to print Fibonacci series up to n terms. 40-41

22 Design the following form when user clicks on Radio Button 42-43
then selectCheckbox.

6
7
23 Design the Digital watch using Timer Control. 44-45

24 Design the following form using horizontal scrollbar. In this, 46-47


when user click onparticular scrollbar then back color of
shape will be changed to Red, Green & Blue color

25 Design the following form using vertical scrollbar. In this, 48-49


when user click on particular scrollbar then back color of
shape will be changed to Red, Green & Blue color

26 Design the form with different controls. 50-52

27 WAP for Exception handling of throwing an exception when 53


dividing by zero condition occur during arithmetic operation.
28 WAP in vb.net such that throw a user define exception when 54-55
Temperature is zero.

8
29 Design from that shows the functionality of listbox 56-58

30 Write a vb.net program to show data in Data grid view. 59-60

31 Create following table Student(id,name,course,DOB,address) 61-62


Write vb.net application to
1. Add records
2. View all the records

32 Develop a project which displays the student information in the 63-64


relevant fields from the database which already exists.

33 Define structure student. Structure student has data members65-66


for storing name, rollno ,name of three subjects and marks.
Write member function to store and print data.

34 Write a class having name Calculate that uses static overloaded 67-68
function to calculate area of circle, area of rectangle and area
of triangle.
35 WAP to check whether a given number is neon or not using 69-70
user define function
36 WAP to check whether a given number is Niven or not 71-72
using procedure
37 WAP to check whether a given number is Duck number or not . 73-74

38 WAP to check whether a given number is Spy number or not . 75-76

9
39 Write a program to find first and last digit of any number. 77-78

40 Write a program to enter any number and print its reverse. 79-80

41 WAP to check whether a given number is Armstrong number 81-82


or not.
42 WAP to enter any number and check whether the no. 83-84
is palindrome or not.
43 WAP to calculate factorial of a number using user define 85-86
procedure.
44 Create a class circle with data member radius; provide member87-88
functionto calculate area. Define a class sphere from class circle,
provide member function to calculate area class cylinder
from class sphere with additional data memberfor height
and member function to calculate volume.

10
Q1.Write a program to find maximum between three numbers.

CODE –

Module Module1
Sub Main()
Dim a, b, c As Integer
Console.WriteLine("Enter the first number - ")
a = Console.ReadLine()
Console.WriteLine("Enter the second number - ")
b = Console.ReadLine()
Console.WriteLine("Enter the third number - ")
c = Console.ReadLine()
If (a > b) Then
If (a > c) Then
Console.WriteLine("A is the greatest number")
Else
Console.WriteLine("C is the greatest number")
End If
Else
If (b > c) Then
Console.WriteLine("B is the greatest number")
Else
Console.WriteLine("C is the greatest number")
End If
End If
Console.ReadLine()

11
End Sub
End Module

OUTPUT –

12
Q.1 Write a program to check whether a number is negative,
positive or zero.

CODE –
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles
Button1.Click
If (0 < TextBox1.Text) Then
MsgBox("Number is positive")
ElseIf (0 > TextBox1.Text) Then
MsgBox("number is negative")
Else
MsgBox("number is zero")
End If
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles
Button2.Click
End
End Sub
End Class
Output –

13
Q.2 Write a program to check whether a year is leap year or not.

CODE –

Module Module1
Sub Main()
Dim year As Integer
Console.WriteLine("Enter the year : -")
year = Console.ReadLine()
If (year Mod 4 = 0 And year Mod 100 <> 0 Or year Mod 400 = 0 Then
Console.WriteLine("this is leap year")
Else
Console.WriteLine("this is not leap year")
End If
Console.ReadLine()
End Sub
End Module

OUTPUT -

14
Q.3 Write a program to check whether a character is alphabet or
not.
CODE -
Module Module1
Sub Main()
Dim c As Char
Dim i As Integer
Console.WriteLine("*** Program to check character is Alphabet or Not *
**")
Console.WriteLine()
Console.Write(" Enter a character :- ")
c = Console.ReadLine()
i = Asc(c)
If ((i >= 97 And i <= 122) Or (i >= 65 And i <= 90)) Then
Console.WriteLine(" {0} is a Character", c)
Else
Console.WriteLine(" {0} is not a Character", c)
End If
Console.ReadLine()
End Sub
End Module
OUTPUT -

15
Q.4

16
Write a program to find all roots of a quadratic equation.

CODE -
Module Module1

Sub Main()
Dim a, b, c, r1, r2 As Single
Console.WriteLine("*** Program to find all Roots of a Quadration
Equation ***")
Console.WriteLine()
Console.Write(" Enter the value of A :- ")
a = Console.ReadLine()
Console.Write(" Enter the value of B :- ")
b = Console.ReadLine()
Console.Write(" Enter the value of C :- ")
c = Console.ReadLine()
Console.WriteLine()
Dim d As Integer = b ^ 2 - 4 * a * c
If d = 0 Then
Console.WriteLine(" Roots are real and equal.")
r1 = -b / (2 * a)
Console.WriteLine(" Root1 = Root2 = {0}", r1)
ElseIf d > 0 Then
Console.WriteLine(" Roots are real and different.")
r1 = (-b + d ^ 0.5) / (2 * a)
r2 = (-b - d ^ 0.5) / (2 * a)
Console.WriteLine(" Root1 = {0}, Root2 = {0}", r1, r2)

17
Else

18
Console.WriteLine(" Roots are complex and different.")
Console.Write(" Root1 = ")
Console.WriteLine(-b / (2 * a) & "+" & (d * -1) ^ 0.5 / (2 * a) & "i")
Console.Write(" Root2 = ")
Console.WriteLine(-b / (2 * a) & "-" & (d * -1) ^ 0.5 / (2 * a) & "i")
End If
Console.ReadLine()
End Sub

End Module

OUTPUT -

19
Q.5 Design an application to input marks of five subjects physics,
chemistry, biology, mathematics and computer. Calculate
percentage and grade according to following: Percentage>=90% :
grade A Percentage>=80% : grade B Percentage>=70% : grade C
Percentage>=60% : grade C Percentage>=40% : grade E
Percentage.

CODE :

Public Class Form1

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


Button1.Click
Dim total As Integer
Dim number1, number2, number3, number4, number5 As Integer

20
number1 = TextBox1.Text

21
number2 = TextBox2.Text
number3 = TextBox3.Text
number4 = TextBox4.Text
number5 = TextBox5.Text
total = number1 + number2 + number3 + number4 + number5
Dim percentage As Integer
percentage = total / 5
TextBox6.Text = percentage
If (percentage >= 90) Then
TextBox7.Text = "A"
ElseIf (percentage >= 80) Then
TextBox7.Text = "B"
ElseIf (percentage >= 70) Then
TextBox7.Text = "C"
ElseIf (percentage >= 60) Then
TextBox7.Text = "D"
ElseIf (percentage >= 40) Then
TextBox7.Text = "E"
Else
TextBox7.Text = "F"
End If

End Sub
End Class

22
OUTPUT -

23
Q.6 Design an application to input basic salary of an employee
and Gross salary according to following:
Basic Salary
<=10000 :HRA=20%,DA=80% Basic
Salary <=20000 :HRA=25%,DA=90%
Basic Salary >10000 :HRA=30%,DA=95%

CODE -
Public Class Form1
Dim BS, hra, da, gs As Integer
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles
Button1.Click
BS = InputBox("Basic Salary")
TextBox1.Text = BS

24
End Sub

25
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles
Button2.Click
If BS <= 10000 Then
hra = BS * 20 / 100
da = BS * 80 / 100
ElseIf BS <= 20000 Then
hra = BS * 25 / 100
da = BS * 90 / 100
Else
hra = BS * 30 / 100
da = BS * 95 / 100
End If
gs = BS + hra + da
TextBox2.Text = gs
End Sub
End Class

OUTPUT -

26
8 Design an application which is similar to login from.

CODE -

Public Class Form1

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


Button2.Click
End
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles
Button1.Click
If TextBox1.Text = Nothing Or TextBox2.Text = Nothing Then
MsgBox("fill up the details", MsgBoxStyle.Critical)
ElseIf TextBox1.Text = "admin" And TextBox2.Text = "ishu@123" Then
MsgBox("login successfully")
Else

27
MsgBox("account not exits", MsgBoxStyle.Critical)
End If
End Sub

End Class

28
Q.9 WAP using checkbox for the following font effects.
Bold , Italic , Underline , Increase font size ,Decrease font size
,Font color.

CODE : -

Public Class Form1


Private Sub CheckBox6_CheckedChanged(sender As Object, e As
EventArgs) Handles CheckBox6.CheckedChanged
If CheckBox6.Checked Then
Label1.ForeColor = Color.Green
Else
Label1.ForeColor = Color.Black
End If
End Sub
Private Sub CheckBox4_CheckedChanged(sender As Object, e As
EventArgs) Handles CheckBox4.CheckedChanged
If CheckBox4.Checked Then
Label1.Font = New Font(Label1.Font.FontFamily, 16, FontStyle.Bold)
Else

29
Label1.Font = New Font(Label1.Font.FontFamily, 12,
FontStyle.Regular)
End If
End Sub
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles
MyBase.Load
Dim Name As String
Name = Label1.Text
End Sub
Private Sub CheckBox1_CheckedChanged(sender As Object, e As
EventArgs) Handles CheckBox1.CheckedChanged
If CheckBox1.Checked Then
Label1.Font = New Font(Label1.Font.FontFamily, Label1.Font.Size,
FontStyle.Bold)
Else
Label1.Font = New Font(Label1.Font.FontFamily, Label1.Font.Size,
FontStyle.Regular)
End If
End Sub
Private Sub CheckBox2_CheckedChanged(sender As Object, e As
EventArgs) Handles CheckBox2.CheckedChanged
If CheckBox2.Checked Then
Label1.Font = New Font(Label1.Font.FontFamily, Label1.Font.Size,
FontStyle.Italic)
Else
Label1.Font = New Font(Label1.Font.FontFamily, Label1.Font.Size,
FontStyle.Regular)
End If
End Sub

30
Q.10 Design the form that calculate Sum, Multiplication, Division
and Subtraction of two number.

CODE :

Public Class Form1

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


Button4.Click
TextBox6.Text = Val(TextBox1.Text) / Val(TextBox2.Text)
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles
Button1.Click
TextBox3.Text = Val(TextBox1.Text) + Val(TextBox2.Text)
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles
Button2.Click
TextBox4.Text = Val(TextBox1.Text) - Val(TextBox2.Text)

31
End Sub

32
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles
Button3.Click
TextBox5.Text = Val(TextBox1.Text) * Val(TextBox2.Text)
End Sub
Private Sub Label1_Click(sender As Object, e As EventArgs) Handles

End Class

OUTPUT -

33
Q. 11 Design Simple calculator.

Controls Properties Changes


Button1- Button16 Text , FontSize 0-9 , 10.8

TextBox1 FontSize , FontStyle 12, Bold

CODE –

Public Class Form1


Dim value1, value2 As Integer
Dim sign As String
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles
Button1.Click
TextBox1.Text = TextBox1.Text & 1
End Sub
Private Sub Button4_Click(sender As Object, e As EventArgs) Handles
Button4.Click
34
Dot Net Technology

TextBox1.Text = TextBox1.Text & 2


End Sub
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles
Button3.Click
TextBox1.Text = TextBox1.Text & 3 End
Sub
Private Sub Button8_Click(sender As Object, e As EventArgs) Handles
Button8.Click
TextBox1.Text = TextBox1.Text & 4
End Sub
Private Sub Button5_Click(sender As Object, e As EventArgs) Handles
Button5.Click
TextBox1.Text = TextBox1.Text & 5
End Sub
Private Sub Button6_Click(sender As Object, e As EventArgs) Handles
Button6.Click
TextBox1.Text = TextBox1.Text & 6
End Sub
Private Sub Button12_Click(sender As Object, e As EventArgs) Handles
Button12.Click
TextBox1.Text = TextBox1.Text & 7
End Sub
Private Sub Button9_Click(sender As Object, e As EventArgs) Handles
Button9.Click
TextBox1.Text = TextBox1.Text & 8
End Sub
Private Sub Button10_Click(sender As Object, e As EventArgs) Handles
Button10.Click
TextBox1.Text = TextBox1.Text & 9
End Sub
P a g e 35 |
Dot Net Technology

Private Sub Button16_Click(sender As Object, e As EventArgs) Handles


Button16.Click
TextBox1.Text = TextBox1.Text & 0
End Sub
Private Sub Button13_Click(sender As Object, e As EventArgs) Handles
Button13.Click
TextBox1.Text = " "
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles
Button2.Click
value1 = TextBox1.Text
TextBox1.Clear()
TextBox1.Focus()
sign = "+"
End Sub
Private Sub Button7_Click(sender As Object, e As EventArgs) Handles
Button7.Click
value1 = TextBox1.Text
TextBox1.Clear()
TextBox1.Focus()
sign = "-"
End Sub
Private Sub Button11_Click(sender As Object, e As EventArgs) Handles
Button11.Click
value1 = TextBox1.Text
TextBox1.Clear()
TextBox1.Focus()
sign = "*"
End Sub
P a g e 36 |
Private Sub Button15_Click(sender As Object, e As EventArgs) Handles
Button15.Click
value1 = TextBox1.Text
TextBox1.Clear()
TextBox1.Focus()
sign = "/"
End Sub
Private Sub Button14_Click(sender As Object, e As EventArgs) Handles
Button14.Click
value2 = TextBox1.Text
If sign = "+" Then
TextBox1.Text = value1 + value2
ElseIf sign = "-" Then
TextBox1.Text = value1 - value2
ElseIf sign = "*" Then
TextBox1.Text = value1 * value2
Else : sign = "/"
TextBox1.Text = value1 / value2
End If
End Sub
End Class

OUTPUT -

I P a g e 37 |
Q.12 Design the form to input radius of a circle and find its
circumference and area.

CODE : -

Public Class Form1


Dim radius, area, circ As Double
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles
Button1.Click
radius = TextBox1.Text
area = 3.14 * radius * radius
TextBox2.Text = area
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles
Button2.Click
circ = 2 * 3.14 * radius
TextBox3.Text = circ
End Sub

I P a g e 38 |
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles
MyBase.Load
End Sub
End Class

OUTPUT -

I P a g e 39 |
Q.13 Design the form to input length in centimeter and convert it
into meter.

CODE :

Public Class Form1


Dim change As Double
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles
Button1.Click
change = TextBox1.Text / 100
TextBox2.Text = change
End Sub
End Class

OUTPUT –

I P a g e 40 |
Q.14 Design the form to input temperature in Celsius and convert
it into Fahrenheit.

CODE -
Public Class Form1

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


Button1.Click
Dim calcuis As Integer
Dim farenheight As Double
calcuis = TextBox1.Text
farenheight = (calcuis * 1.8) + 32
TextBox2.Text = farenheight
End Sub

End Class

OUTPUT -

I P a g e 41 |
Q.15 Design the form to input Principal amount, Time, Rate and
calculate Simple Interest and compound interest show result
information in msgbox.

CODE : -
Public Class Form1

Private Sub Button1_Click(sender As Object, e As EventArgs)


Handles Button1.Click
Dim p, r, t, si As Integer
p = TextBox1.Text
r = TextBox2.Text
t = TextBox3.Text
si = p * r * t / 100
MsgBox("simple intrest is : " & si)
Dim Ap, a As Double
Ap = p * (1 + r / 100) ^ t

I P a g e 42 |
a = Ap - p
MsgBox("compound intrest is : " & si)
End Sub

End Class

OUTPUT -

I P a g e 43 |
Q.16 Design the form and write a program to sort array element
in ascending order.

CODE :

Public Class Form1


Dim arr() As Integer = {2, 4, 1, 3, 5}
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles
Button1.Click
ListBox1.Items.Clear()
Dim i As Integer = 0
For i = 0 To arr.Count - 1
ListBox1.Items.Add(arr(i))
Next
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles
Button2.Click
Dim i As Integer = 0
Dim j As Integer = 0
I P a g e 44 |
For i = 0 To arr.Count - 1
For j = i + 1 To arr.Count - 1
If arr(i) > arr(j) Then
Dim k As Integer
k = arr(j)
arr(j) = arr(i)
arr(i) = k
End If
Next
Next
For i = 0 To arr.Count - 1
ListBox2.Items.Add(arr(i))
Next
End Sub

End Class

OUTPUT –

I P a g e 45 |
Q.17 Design the form and write a program to insert an element
in an array.

Controls Properties Changes


ListBox1 Items, FontSize Array , 12

Button1 Text , FontSize Add Element , 12

CODE :-

Public Class Form1


Private Sub Button1_Click(sender As Object, e As EventArgs) Handles
Button1.Click
Dim i As Integer
Dim number(3) As Integer
For i = 0 To number.Length - 1
Dim element As Integer
element = InputBox("Enter a value")
number(i) = element
Next
For i = 0 To number.Length - 1
I P a g e 46 |
ListBox1.Items.Add(number(i))
Next
End Sub
End Class
OUTPUT -

I P a g e 47 |
Q.18 Design the form and write a program to delete an
element from an array at specified position.

CODE :

Public Class Form1


Dim arr As Integer() = {453, 23, 544, 657, 90, 23}
Dim flag As Integer = 0
Dim item As Integer = 0
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles
Button1.Click
For i = 0 To 5 Step 1
ListBox1.Items.Add(arr(i))
Next
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles
Button2.Click
item = TextBox1.Text
flag = 0
I P a g e 48 |
For i = 0 To 5 Step 1
If (i = item) Then
flag = 1
For j = i To 4 Step 1
arr(j) = arr(j + 1)
Next
End If
Next
For i = 0 To (5 - flag) Step 1
ListBox2.Items.Add(arr(i))
Next
End Sub
End Class

OUTPUT –

I P a g e 49 |
Q.19 Design the form and write a program to print all unique
elements in the array.

CODE : -

Public Class Form1


Dim arr() As Integer = {9, 9, 8, 1, 3, 6, 9, 7, 1, 2}
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles
Button2.Click
ListBox2.Items.Clear()
Dim i As Integer
Dim j As Integer
For i = 0 To arr.Length - 1
Dim flag As Boolean = False
For j = 0 To arr.Length - 1
If arr(i) = arr(j) And i <> j Then
flag = True
End If
I P a g e 50 |
Next
If flag = False Then
ListBox2.Items.Add(arr(i))
End If
Next
End Sub
Private Sub Button1_Click_1(sender As Object, e As EventArgs) Handles
Button1.Click
Dim i As Integer
ListBox1.Items.Clear()
For i = 0 To arr.Length - 1
ListBox1.Items.Add(arr(i))
Next
End Sub
End Class

OUTPUT -

I P a g e 51 |
Q.20 Design a form to check whether a number is PRIME or
NOT using input box and msgbox.

CODE : -

Public Class Form1


Private Sub Button1_Click(sender As Object, e As EventArgs) Handles
Button1.Click
Dim i, flay As Integer
Dim n As Integer
n = InputBox("Enter the number", "check prime number or not")
TextBox1.Text = n
flay = 0
For i = 2 To n - 1
If (n Mod i = 0) Then
flay = 1
Exit For
End If

I P a g e 52 |
Next
If (flay <> 0) Then
TextBox2.Text = "not prime number"
MsgBox("not prime number")
Else
TextBox2.Text = "prime number"
MsgBox("prime number")
End If
End Sub
End Class

OUTPUT –

I P a g e 53 |
Q.21 Write a program to print Fibonacci series up to n terms.

CODE –

Module Module1
Sub Main()
Dim length, number1, number2, total As Integer
Console.WriteLine("Enter the length ")
length = Console.ReadLine()
Console.WriteLine("Enter the first and second number")
number1 = Console.ReadLine()
number2 = Console.ReadLine()
Console.Write(number1 & " " & number2 & " ")
For i = 1 To length - 1
total = number1 + number2
Console.Write(total & " ")
number1 = number2
number2 = total
Next
Console.ReadLine()
End Sub
End Module

I P a g e 54 |
OUTPUT –

I P a g e 55 |
Q.22 Design the following form when user clicks on Radio Button
then select Checkbox.

CODE : -

Public Class Form1


Private Sub RadioButton3_CheckedChanged(sender As Object, e As
EventArgs) Handles RadioButton3.CheckedChanged
If RadioButton3.Checked Then
CheckBox2.CheckState = CheckState.Checked
Else
CheckBox2.CheckState = CheckState.Unchecked
End If
End Sub
Private Sub RadioButton4_CheckedChanged(sender As Object, e As
EventArgs) Handles RadioButton4.CheckedChanged
If RadioButton4.Checked Then
CheckBox1.CheckState = CheckState.Checked
CheckBox3.CheckState = CheckState.Checked
Else
I P a g e 56 |
CheckBox1.CheckState =
CheckState.Unchecked CheckBox3.CheckState
= CheckState.Unchecked End If
End Sub
Private Sub RadioButton5_CheckedChanged(sender As Object, e As
EventArgs) Handles RadioButton5.CheckedChanged
If RadioButton5.Checked Then
CheckBox1.CheckState = CheckState.Checked
CheckBox3.CheckState = CheckState.Checked
Else
CheckBox1.CheckState =
CheckState.Unchecked CheckBox3.CheckState
= CheckState.Unchecked End If
End Sub
End Class

OUTPUT –

I P a g e 57 |
Q.23 Design the Digital watch using Timer Control.

Controls Properties Changes


Button1 Text ,FontSize, FontStyle START, 10.2 , Bold

Button2 Text ,FontSize, FontStyle STOP, 10.2 , Bold

Button3 Text ,FontSize, FontStyle RESET , 10.2 , Bold

Label1 Text , FontSize , FontStyle 00:00:00, 13.8, Bold

CODE
Public Class Form1

Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles


Timer1.Tick
Label1.Text = Date.Now.ToString(" hh:mm:ss tt")
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles
Button2.Click
I P a g e 58 |
Timer1.Enabled = False
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles
Button1.Click
Timer1.Enabled = True
End Sub
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles
Button3.Click
Label1.Text = "00:00:00"
Timer1.Enabled = False
End Sub

End Class

OUTPUT –

I P a g e 59 |
Q.24 Design the following form using horizontal scrollbar. In this,
when user click on particular scrollbar then back color of shape
will be changed to Red, Green & Blue color.

CODE –

Public Class Form1

Private Sub HScrollBar2_Scroll(sender As Object, e As ScrollEventArgs)


Handles HScrollBar2.Scroll
Label2.BackColor = Color.Green
End Sub
Private Sub HScrollBar1_Scroll(sender As Object, e As ScrollEventArgs)
Handles HScrollBar1.Scroll
Label1.BackColor = Color.Red
End Sub
Private Sub HScrollBar3_Scroll(sender As Object, e As ScrollEventArgs)
Handles HScrollBar3.Scroll
Label3.BackColor = Color.Blue

I P a g e 60 |
End Sub
End Class

OUTPUT -

I P a g e 61 |
Q.25 Design the following form using vertical scrollbar. In this,
when user click on particular scrollbar then back color of shape
will be changed to Red, Green &Blue color.

Controls Properties Changes


Form Text ,BackColor Form1, White

VScrollBar1 Name , TabIndex VScrollBar1, 2

VScrollBar2 Name , TabIndex VScrollBar2, 2

VScrollBar3 Name , TabIndex VScrollBar3, 2

Panel1 BackColor , BorderStyle ButtonHighlight, FixedSignle

CODE -

Public Class Form1

Private Sub VScrollBar1_Scroll(sender As Object, e As ScrollEventArgs)


Handles VScrollBar1.Scroll

I P a g e 62 |
Panel1.BackColor = Color.Red
End Sub
Private Sub VScrollBar2_Scroll(sender As Object, e As ScrollEventArgs)
Handles VScrollBar2.Scroll
Panel1.BackColor = Color.Green
End Sub
Private Sub VScrollBar3_Scroll(sender As Object, e As ScrollEventArgs)
Handles VScrollBar3.Scroll
Panel1.BackColor = Color.Blue
End Sub
End Class
OUTPUT –

I P a g e 63 |
Q.26 Design the form with different controls.

CODE :
Public Class Form1

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


Button1.Click
Dim accessories As String
Dim processor As String
Dim OS As String
If CheckBox1.Checked Then
accessories = CheckBox1.Text
ElseIf CheckBox2.Checked Then
accessories = CheckBox2.Text
ElseIf CheckBox3.Checked Then
accessories = CheckBox3.Text
ElseIf CheckBox4.Text Then
accessories = CheckBox4.Text
Else
I P a g e 64 |
MsgBox("select any accessories ")
End If
If CheckBox1.Checked And CheckBox2.Checked
Then accessories = CheckBox1.Text + " " +
CheckBox2.Text End If
If CheckBox3.Checked And CheckBox4.Checked
Then accessories = CheckBox3.Text + " " +
CheckBox4.Text End If
If CheckBox4.Checked And CheckBox1.Checked
Then accessories = CheckBox4.Text + " " +
CheckBox1.Text End If
If CheckBox1.Checked And CheckBox3.Checked
Then accessories = CheckBox1.Text + " " +
CheckBox3.Text End If
If CheckBox2.Checked And CheckBox4.Checked
Then accessories = CheckBox2.Text + " " +
CheckBox4.Text End If
If CheckBox2.Checked And CheckBox4.Checked And CheckBox3.Checked
Then
accessories = CheckBox2.Text + " " + CheckBox4.Text + " " +
CheckBox3.Text
End If
If CheckBox1.Checked And CheckBox2.Checked And CheckBox3.Checked
And CheckBox4.Checked Then
accessories = CheckBox1.Text + " " + CheckBox2.Text + " " +
CheckBox3.Text + " " + CheckBox4.Text
End If
If RadioButton1.Checked Then
processor = RadioButton1.Text
I P a g e 65 |
ElseIf RadioButton2.Checked Then
processor = RadioButton2.Text
ElseIf RadioButton3.Checked Then
processor = RadioButton3.Text
Else
MsgBox("Select any processor")
End If
If RadioButton4.Checked Then
OS = RadioButton4.Text
ElseIf RadioButton5.Checked Then
OS = RadioButton5.Text
Else
MsgBox("Select any Operating System")
End If
TextBox1.Text = "You Selected a " + processor + " with " + OS + " and
accessories " + accessories + " ."
End Sub
End Class
OUTPUT –

I P a g e 66 |
Q.27 WAP for Exception handling of throwing an exception when
dividing by zero condition occur during arithmetic operation.
CODE -

Module Module1
Sub Main()
Dim number1, number2, div As Integer
number1 = 9
number2 = 0
Console.WriteLine("number1 = " & number1 & " number2 = " & number2)
Try
div = number1 / number2
Catch ex As Exception
Console.WriteLine("Can't divided by ZERO")
End Try
Console.WriteLine(div)
Console.ReadLine()
End Sub
End Module

OUTPUT -

I P a g e 67 |
Q.28 WAP in vb.net such that throw a user define exception when
Temperature is zero

CODE –

Module Module1
Public Class erroeHandleeee : Inherits Exception
Sub New()
MyBase.New(" Error accured")
End Sub
End Class
Sub Main()
Dim temp As Integer
Console.WriteLine()
Console.Write(" Enter the temp : ")
temp = Console.ReadLine
Console.WriteLine()
Try
If temp <> 0 Then
Console.WriteLine(" temperature is " & temp)
Else
Throw New erroeHandleeee()
End If
Catch ex As erroeHandleeee
Console.WriteLine(" user defined error handled")
End Try
Console.ReadLine()
End Sub
I P a g e 68 |
End Module

OUTPUT -

I P a g e 69 |
Q.29 Design from that shows the functionality of listbox.

CODE :
Public Class Form1
Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
ListBox1.Items.Add("Yellow")
ListBox1.Items.Add("black")
ListBox1.Items.Add("white")
ListBox1.Items.Add("green")
ListBox2.Items.Add("car")
ListBox2.Items.Add("bike")
ListBox2.Items.Add("bus")
ListBox2.Items.Add("train")
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles
Button1.Click
ListBox2.Items.Add(ListBox1.SelectedItem)
ListBox1.Items.RemoveAt(ListBox1.SelectedIndex)
End Sub
I P a g e 70 |
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles
Button3.Click
ListBox1.Items.Add(ListBox2.SelectedItem)
ListBox2.Items.RemoveAt(ListBox2.SelectedIndex)
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles
Button2.Click
ListBox2.Items.AddRange(ListBox1.Items)
ListBox1.Items.Clear()
End Sub
Private Sub Button4_Click(sender As Object, e As EventArgs) Handles
Button4.Click
ListBox1.Items.AddRange(ListBox2.Items)
ListBox2.Items.Clear()
End Sub

Private Sub Button8_Click(sender As Object, e As EventArgs) Handles


Button8.Click
ListBox1.Sorted = True
End Sub
Private Sub Button7_Click(sender As Object, e As EventArgs) Handles
Button7.Click
ListBox1.Items.Clear()
End Sub
Private Sub Button5_Click(sender As Object, e As EventArgs) Handles
Button5.Click
ListBox1.Items.Add(InputBox("Enter a value "))
End Sub
Private Sub Button6_Click(sender As Object, e As EventArgs) Handles
Button6.Click
I P a g e 71 |
ListBox1.Items.RemoveAt(ListBox1.SelectedIndex)
End Sub
End Class

OUTPUT -

I P a g e 72 |
Q.30 Write a vb.net programto show data in Data grid view.

Controls Properties Changes


DataGridView1 BackgroundColor AppWorkSpace

CODE : -
Public Class Form1

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


MyBase.Load
'TODO: This line of code loads data into the 'Database1DataSet.Table1' table.
You can move, or remove it, as needed.
Me.Table1TableAdapter.Fill(Me.Database1DataSet.Table1)

End Sub
End Class

I P a g e 73 |
OUTPUT -

I P a g e 74 |
Q. 31 Create following table Student (id,name ,course ,DOB
,address) Write vb.net application to
1. Add records
2. View all the records.

CODE : -
Public Class Form1

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


MyBase.Load
'TODO: This line of code loads data into the 'Database1DataSet.Table1'
table. You can move, or remove it, as needed.
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles
Button1.Click
Table1BindingSource.AddNew()
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles
Button2.Click
Me.Table1TableAdapter.Fill(Me.Database1DataSet.Table1)
End Sub

I P a g e 75 |
End Class
OUTPUT –

I P a g e 76 |
Q.32 Develop a project which displays the student information in
the relevant fields from the database which already exists.

CODE :
Public Class Form1

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


MyBase.Load
'TODO: This line of code loads data into the 'Database1DataSet.Table1' table.
You can move, or remove it, as needed.
Me.Table1TableAdapter.Fill(Me.Database1DataSet.Table1)
End Sub
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles
Button3.Click
Table1BindingSource.MovePrevious()
End Sub
Private Sub Button5_Click(sender As Object, e As EventArgs) Handles
Button5.Click
End
End Sub

I P a g e 77 |
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles
Button1.Click
Table1BindingSource.MoveFirst()
End Sub
Private Sub Button4_Click(sender As Object, e As EventArgs) Handles
Button4.Click
Table1BindingSource.MoveLast()
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles
Button2.Click
Table1BindingSource.MoveNext()
End Sub
End Class

OUTPUT –

I P a g e 78 |
Q.33 Define structure student. Structure student has data
members for storing name, rollno ,name of three subjects and
marks. Write member function to store and print data.

CODE –

Module Module1
Structure Struct
Public name As String
Public rollno As Integer
Public maths As Integer
Public physics As Integer
Public chemistry As Integer
Public Sub input()
Console.WriteLine("Ente the student details ")
Console.WriteLine()
Console.Write("name : ")
name = Console.ReadLine()
Console.Write("Roll no. : ")
rollno = Console.ReadLine()
Console.Write("Maths : ")
maths = Console.ReadLine()
Console.Write("Physics : ")
physics = Console.ReadLine()
Console.Write("Chemistry : ")
chemistry = Console.ReadLine
End Sub
Public Sub display()
I P a g e 79 |
Console.WriteLine(" ")
Console.WriteLine()
Console.WriteLine("student marksheet")
Console.WriteLine("name : " & name)
Console.WriteLine("Roll no. : " & rollno)
Console.WriteLine("Maths : " & maths)
Console.WriteLine("Physics : " & physics)
Console.WriteLine("Chemistry : " & chemistry)
Console.ReadLine()
End Sub
End Structure
Sub Main()
Dim st As Struct
st.input()
st.display()
End Sub
End Module
OUTPUT –

I P a g e 80 |
Q.34 Write a class having name Calculate that uses static
overloaded function to calculate area of circle, area of
rectangle and area of triangle.

CODE –

Module Module1
Public Class Calculate
Shared Sub area(ByVal r As Integer)
Console.WriteLine()
Console.Write("Area of Circle :- ")
Console.WriteLine(Math.PI * r * r)
End Sub
Shared Sub area(ByVal l As Double, ByVal h As Double)
Console.WriteLine()
Console.Write("Area of Rectangle :- ")
Console.WriteLine(l * h)
End Sub
Shared Sub area(ByVal b As Integer, ByVal p As Integer)
Console.WriteLine()
Console.Write("Area of Triangle :- ")
Console.WriteLine(1 / 2 * b * p)
End Sub
End Class
Sub Main()
Dim obj As Calculate = New Calculate()
Calculate.area(5)
Calculate.area(5.0, 3.0)
I P a g e 81 |
Calculate.area(4, 3)
Console.ReadLine()
End Sub
End Module

OUTPUT –

I P a g e 82 |
Q.35 WAP to check whether a given number is neon number or
not using user define function.

CODE –

Module Module1
Dim n As Integer
Dim sqaure As Integer
Dim sum As Integer
Sub Main()
Console.WriteLine("*** check given number is neon number or not ***")
Console.WriteLine()
Console.Write(" Enter a no : ")
n = Console.ReadLine()
sqaure = n * n
display()
End Sub
Function display()
While sqaure > 0
sum = sum + sqaure Mod 10
sqaure = sqaure \ 10
End While
If sum = n Then
Console.WriteLine(" neon number")
Else
Console.WriteLine(" not a neon number")
End If

I P a g e 83 |
Console.ReadLine()
Return 0
End Function
End Module

OUTPUT -

I P a g e 84 |
Q.36 WAP to check whether a given number is Niven number or
not using procedure.

CODE –

Module Module1
Sub Main()
Dim num As Integer
Dim remaining = 0, sum = 0, n As Integer
Console.WriteLine("*** check given number is Niven number or not
***")
Console.WriteLine()
Console.Write(" Enter number : ")
num = Console.ReadLine()
n = num
While (num > 0)
remaining = num Mod 10
sum = sum + remaining
num = num \ 10
End While
If (n Mod sum = 0) Then
Console.WriteLine(" niven number")
Else
Console.WriteLine(" not a niven number")
End If
Console.ReadLine()
End Sub

I P a g e 85 |
End Module

OUTPUT –

I P a g e 86 |
Q.37 WAP to check whether a given number is duck number or
not.

CODE –

Sub Main()
Dim n, i, r As Integer
r=0
Console.WriteLine("*** Check Given Number is Duck number or Not ***")
Console.WriteLine()
Console.Write("Enter a no : ")
n = Console.ReadLine
While n <> 0
i = n Mod 10
If i = 0 Then
r=r+1
End If
n = n \ 10
End While
If r >= 1 Then
Console.WriteLine("duck number")
Else
Console.WriteLine("not a duck number")
End If
Console.ReadLine()
End Sub

End Module
I P a g e 87 |
OUTPUT –

I P a g e 88 |
Q.38 WAP to check whether a given number is spy number or
not.

CODE –

Module Module1

Sub Main()
Dim num, product, sum, lastdigit As Integer
product = 1
sum = 0
Console.WriteLine("*** check given number is spy number or not ****")
Console.WriteLine()
Console.Write(" Enter the number to check : ")
num = Console.ReadLine()
While (num > 0)
lastdigit = num Mod 10
sum = sum + lastdigit
product = product * lastdigit
num = num / 10
End While
If sum = product Then
Console.WriteLine(" The given number is a spy number")
Else
Console.WriteLine(" The given number is not spy number")
End If
Console.ReadLine()

I P a g e 89 |
End Sub

End Module

OUTPUT -

I P a g e 90 |
Q.39 Write a program to find first and last digit of any number.

CODE –

Module Module1
Dim n As Integer
Sub Main()
Console.WriteLine()
Console.Write(" Enter number : ")
n = Console.ReadLine
Console.WriteLine()
Console.WriteLine(" First digit is " & firstDigit(n) & " and " & "last digit is "
& lastDigit(n))
Console.ReadLine()
End Sub
Function firstDigit(n)
While (n >= 10)
n \= 10
End While
Return n
End Function
Function lastDigit(n)
Return (n Mod 10)
End Function
End Module

I P a g e 91 |
OUTPUT -

I P a g e 92 |
Q. 40 Write a program to enter any number and print its reverse.

CODE –
Module Module1
Sub Main()
Dim number As Integer = 0
Dim remainder As Integer = 0
Dim reverse As Integer = 0
Console.WriteLine(" *** Reverse number: *** ")
Console.Write("Enter the number: ")
number = Integer.Parse(Console.ReadLine())
While (number > 0)
remainder = number Mod 10
reverse = reverse * 10 + remainder
number = number / 10
End While
Console.WriteLine("Reverse: {0}", reverse)
Console.ReadLine()
End Sub
End Module

I P a g e 93 |
OUTPUT –

I P a g e 94 |
Q.41 WAP to check whether a given number is Armstrong or not.

CODE –

Module module1
Sub Main(args As String())
Dim n As Integer, r, temp As Integer, sum As Integer = 0
Console.WriteLine("*** Check given number is Armstrong or not ***")
Console.WriteLine()
Console.Write(" Enter the Number : ")
n = Integer.Parse(Console.ReadLine())
temp = n
While n > 0
r = n Mod 10
sum = sum + (r * r * r)
n = n \ 10
End While
If temp = sum Then
Console.Write(" Armstrong Number.")
Else
Console.Write(" Not Armstrong Number.")
End If
Console.ReadLine()
End Sub
End Module

I P a g e 95 |
OUTPUT -

I P a g e 96 |
Q.42 WAP to enter any number and check whether the no.
is palindrome or not.

CODE -

Module Module1

Sub Main()
Console.WriteLine("*** check numbers is palindrome number or not ***")
Console.WriteLine()
Dim n, r, temp As Integer, sum As Integer = 0
Console.Write(" Enter the Number: ")
n = Integer.Parse(Console.ReadLine())
temp = n
While n > 0
r = n Mod 10
sum = (sum * 10) + r
n = n / 10
End While
If temp = sum Then
Console.Write(" Number is Palindrome.")
Else
Console.Write(" Number is not Palindrome")
End If
Console.ReadLine()

I P a g e 97 |
End Sub

End Module

OUTPUT –

I P a g e 98 |
Q.43 WAP to calculate factorial of a number using user define
procedure.

CODE –

Module Module1
Dim i, number As Integer, fact As Integer = 1
Sub Main()
Console.WriteLine("*** Calculate Factorial of given number ***")
Console.WriteLine()
Console.Write(" Enter number : ")
number = Integer.Parse(Console.ReadLine())
fac()
Console.ReadLine()
End Sub
Sub fac()
For i = 1 To number
fact = fact * i
Next
Console.WriteLine()
Console.WriteLine(" Factorial of " & number & " is :" & fact)
End Sub
End Module

I P a g e 99 |
OUTPUT -

I P a g e 100 |
Q.44 Create a class circle with data member radius; provide
member function to calculate area. Define a class sphere
from class circle, provide member function to calculate area
class cylinder from class sphere with additional data member
for height and member function to calculate volume.

CODE -
Module Module1
Class circle
Public radius As Integer
Sub area(ByVal r As Integer)
radius = r
Console.WriteLine("Circle class")
Console.Write(" Area of Circle : ")
Console.WriteLine(Math.PI * radius * radius)
End Sub
End Class
Class sphere
Inherits circle
Sub display()
Console.WriteLine("sphere class")
Console.Write(" Area of Sphere : ")
Console.WriteLine(Math.PI * radius * radius * 4)
End Sub
End Class
Class Cylinder
Inherits sphere
Sub display2(ByVal h1 As Integer)

I P a g e 101 |
Dim h As Integer = h1
Console.WriteLine("Cylinder class")
Console.Write(" Volume of Cylinder : ")
Console.WriteLine(Math.PI * radius * h)
End Sub
End Class
Sub Main()
Dim obj As Cylinder = New Cylinder()
obj.area(5)
obj.display()
obj.display2(6)
Console.ReadLine()
End Sub
End Module

OUTPUT –

I P a g e 102 |

You might also like