0% found this document useful (0 votes)
139 views

RITIK VB - Net Assignment

The document describes an assignment on .NET technology submitted by Ritik Raj, a student of BCA final year at Pragati College to Pt. Ravishankar Shukla University for the academic year 2022-2023, which includes programs to find the maximum of 3 numbers, determine if a number is positive, negative or zero, and other programming exercises.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
139 views

RITIK VB - Net Assignment

The document describes an assignment on .NET technology submitted by Ritik Raj, a student of BCA final year at Pragati College to Pt. Ravishankar Shukla University for the academic year 2022-2023, which includes programs to find the maximum of 3 numbers, determine if a number is positive, negative or zero, and other programming exercises.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 101

AN

ASSIGNMENT
ON
DOT NET TECHNOLOGY
BACHELOR OF COMPUTER APPLICATIONS
FROM
Pt. Ravishankar Shukla University Raipur (C.G)
Final Year
Year: 2022-2023

Guided by Submitted by
Mrs. Minal Chapekar Ritik Raj
(Asst.Professor) (Class BCA -3)

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


and 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 Acknowledge and thanks for the help received from

Mrs. Minal Chapekar our “Assignment In charge” and classmates


who guided me to complete this assignment
CERTIFICATE OF APPROVAL
This is to certify that the assignment work on “VB.Net” is carried out by Ritik
Raj a student of BCA-3 YEAR at PRAGATI COLLEGE is hereby approved as
credible work in the discipline of Database management system for the
award of degree of BCA-2 YEAR during the year 2021-2022 from PT.
RAVISHANKAR SHUKLA UNIVERSITY,RAIPUR(C.G).

Mrs. Minal Chaplekar


Asst. Prof. (Comp. Science Dept.)
PRAGATI COLLEGE, RAIPUR (C.G)
CERTIFICATE OF EVALUATION

This is to certify that the Project work entitled is “DOT NET


TECHNOLOGY” carried out by Ritik Raj a student of BCA-III Year at
Pragati College , Raipur after proper evaluation and examination,
is here by approved as a satisfactory manner for its acceptance as
a requisite for the award of degree of “BCA-III Year "during the year
2022-2023 from Pt. Ravishankar Shukla University, Raipur (CG).

Internal Examiner External Examiner


INDEX
S. No. Name of Program Page Sign
1 Write a program to find maximum between three numbers. 9-10
2 Write a program to check whether a number is negative, positive 11
or
Zero.
3 Write a program to check whether a year is leap year or not. 12
4 Write a program to check whether a character is alphabet or not. 13
5 Write a program to find all roots of a quadratic equation. 14
6 Design an application to input marks of five subjects physics, chemistry, 15-16
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 Gross 17-18
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 19-20
9 WAP using checkbox for the following font effects. 21-24
Bold
Italic
Underline
Increase font size
Decrease font size
Font color
10 Design the form that calculate Sum, Multiplication, Division and 25-26
Subtraction of two number.
11 Design Simple calculator. 27-30
12 Design the form to input radius of a circle and find its circumference 31-32
and area.
13 Design the form to input length in centimeter and convert it into 33-34
meter.
14 Design the form to input temperature in Celsius and convert it into 35-36
Fahrenheit.
15 Design the form to input Principal amount, Time, Rate and calculate 37-38
Simple
Interest and compound interest show result information in msgbox.
16 Design the form and write a program to sort array element in 39-40
ascending
order
17 Design the form and write a program to insert an element in an array. 41-42
18 Design the form and write a program to delete an element from 43-44
an
array at specified position.
19 Design the form and write a program to print all unique elements in 45-46
the array.
20 Design a form to check whether a number is PRIME or NOT using 47-48
input box and msgbox.
21 Write a program to print Fibonacci series up to n terms. 49-50
22 Design the following form when user clicks on Radio Button thenselect 51-52
Checkbox.

23 Design the Digital watch using Timer Control. 53-54

24 Design the following form using horizontal scrollbar. In this, when user 55-56
click on particular scrollbar then back color of shape will be changed
to Red, Green & Blue color

25 Design the following form using vertical scrollbar. In this, when 57-58
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. 59-63


27 WAP for Exception handling of throwing an exception when dividing 64
by zero
condition occur during arithmetic operation.
28 WAP in vb.net such that throw a user define exception when 65-66
Temperature is
zero.
29 Design from that shows the functionality of listbox 67-70

30 Write a vb.net program to show data in Data grid view. 71-72


31 Create following table Student(id,name,course,DOB,address) Write 73-75
vb.net application to
1. Add records
2. View all the records
32 Develop a project which displays the student information in the 76-78
relevant fields from the database which already exists.

33 Define structure student. Structure student has data members for 79-80
storingname, 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 81-84
function
to calculate area of circle, area of rectangle and area of triangle.

7
35 WAP to check whether a given number is neon or not using user define 85-86
function.
36 WAP to check whether a given number is Niven or not using procedure. 87-88

37 WAP to check whether a given number is Duck number or not . 89-90

38 WAP to check whether a given number is Spy number or not . 91-92

39 Write a program to find first and last digit of any number. 93

40 Write a program to enter any number and print its reverse. 94

41 WAP to check whether a given number is Armstrong number or not. 95-96

42 WAP to enter any number and check whether the no. is palindrome or not. 97-98
43 WAP to calculate factorial of a number using user define procedure. 99

44 Create a class circle with data member radius; provide member function to 100-
calculate area. Define a class sphere from class circle, provide member 101
function to calculate area class cylinder from class sphere with additional
data member for height and member function to calculate volume.

8
Q.1) Write a Program to find Maximum between Three Numbers.

Program:-
Imports System
Module Module1

Sub Main()
Dim a As Integer
Dim b As Integer
Dim c As Integer
System.Console.WriteLine("Enter the Value of A =")
a = System.Console.ReadLine()
System.Console.WriteLine("Enter the Value of B =")
b = System.Console.ReadLine()
System.Console.WriteLine("Enter the Value of C =")
c = System.Console.ReadLine()
If (a > b) And (a > c) Then
System.Console.WriteLine("A is Maximum")
System.Console.ReadLine()
ElseIf (b > a) And (b > c) Then
System.Console.WriteLine("B is Maximum")
System.Console.ReadLine()
ElseIf (c > a) And (c > b) Then
System.Console.WriteLine("C is Maximum")
System.Console.ReadLine()
Else
System.Console.WriteLine("Invalid Condition")
End If
End Sub

End Module

9
OUTPUT:-

10
Q.2) Write a Program to check Whether a Number is Negative , Positive
or Zero.

Program:-
Imports System
Module Module1

Sub Main()
Dim a As Integer
System.Console.WriteLine("Enter the Value of A =")
a = System.Console.ReadLine()
If (a > 0) Then
System.Console.WriteLine("A is Positive")
System.Console.ReadLine()
ElseIf (a < 0) Then
System.Console.WriteLine("A is Negative")
System.Console.ReadLine()
End If
End Sub

End Module

OUTPUT:-

11
Q.3) Write a program to check whether a year is leap year or not.
Program:-
Module Module1

Sub Main()
Dim year As Integer
System.Console.WriteLine("Enter any Number :-")
year = System.Console.ReadLine()
If (year Mod 4 = 0 And year Mod 100 <> 0 Or year Mod 400
= 0) Then
System.Console.WriteLine("Leap Year")
System.Console.ReadLine()
Else
System.Console.WriteLine("Not Leap Year")
System.Console.ReadLine()
End If

End Sub

End Module
Output:-

12
Q.4. Write a program to check whether a character is alphabet or not.
Program:-

Imports System

Module Program
Sub Main(args As String())
Dim a As Char
Console.WriteLine("Enter Your Character : ")
a = Console.ReadLine()
Select Case a
Case "a" To "z"
Console.WriteLine("Yes! it is Alphabet : " & a)
Console.ReadLine()

Case "A" To "Z"


Console.WriteLine("Yes! It is Alphabet : " & a)
Console.ReadLine()

Case Else
Console.WriteLine("No! It is Not an Alphabet : " & a)
Console.ReadLine()

End Select
End Sub
End Module

Output:-

13
Q.5) Write a program to find all roots of a quadratic equation.
Program:-
Module Module1

Sub Main()
Dim a, b, c, x1, x2, d As Double
System.Console.WriteLine("Enter value of a,b & c")
a = System.Console.ReadLine()
b = System.Console.ReadLine()
c = System.Console.ReadLine()
d = b * b - 4 * a * c
If (d > 0) Then
x1 = (-b + Math.Sqrt(d)) / 2 * a
x2 = (-b - Math.Sqrt(d)) / 2 * a
System.Console.WriteLine("Root 1->" & x1 & "Root 2-
>" & x2)
System.Console.ReadLine()
Else
System.Console.WriteLine("Roots are Imaginary")
System.Console.ReadLine()
End If

End Sub

End Module

OUTPUT :-

14
Q.6) 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<40% : grade

Program :--
Public Class Form1
Dim Per As Decimal
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles
Button1.Click
Dim GrandTotal As Integer = 500
Dim Total As Integer
Total = CInt(TextBox1.Text) + CInt(TextBox2.Text) +
CInt(TextBox3.Text) + CInt(TextBox4.Text) + CInt(TextBox5.Text)
Per = (Total / GrandTotal) * 100
Label8.Text = Per & " % "
Select Case Per
Case 90 To 100
Label9.Text = " A "
Case 80 To 89
Label9.Text = " B "
Case 70 To 79
Label9.Text = " C "
Case 60 To 69

15
Label9.Text = " D "
Case 40 To 59
Label9.Text = " E "
Case 0 To 39
Label9.Text = " F "
End Select
End Sub

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


Button2.Click
TextBox1.Clear()
TextBox2.Clear()
TextBox3.Clear()
TextBox4.Clear()
TextBox5.Clear()
Label8.Text = " ? "
Label9.Text = " ? "
End Sub
End Class

Output:-

16
Q.7) 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%

Program :-
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs)
Handles Button1.Click
Dim Basic As Integer = CInt(TextBox1.Text)
Dim HRA As Integer
Dim DA As Integer
Select Case Basic
Case 0 To 10000
TextBox2.Text = CStr(0.2 * Basic)
TextBox3.Text = CStr(0.8 * Basic)
Case 10001 To 20000
TextBox2.Text = CStr(0.25 * Basic)
TextBox3.Text = CStr(0.9 * Basic)
Case 20001 To Integer.MaxValue
TextBox2.Text = CStr(0.3 * Basic)
TextBox3.Text = CStr(0.95 * Basic)
End Select
HRA = CInt(TextBox2.Text)
DA = CInt(TextBox3.Text)
TextBox4.Text = CStr(Basic + HRA + DA)
End Sub

17
Private Sub Button2_Click(sender As Object, e As EventArgs)
Handles Button2.Click
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""
End Sub
End Class

Output:-

18
Q.8) Design an application which is similar to Login Form.
Program:-

Public Class Form1

Private Sub Button1_Click_1(sender As Object, e


As EventArgs) Handles Button1.Click
If TextBox1.Text = "ADMIN" And TextBox2.Text
= "ANUJAYSAHAY" Then
MsgBox("LOGIN Successfully")
ElseIf TextBox1.Text = "" Then
MsgBox("Enter Username First",
MsgBoxStyle.Information)
ElseIf TextBox2.Text = "" Then
MsgBox("Enter Password First",
MsgBoxStyle.Information)
Else
MsgBox("Username and Password Is Wrong",
MsgBoxStyle.Critical)
End If
End Sub
End Class

19
OUTPUT:-

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

Program:-
Public Class Form1

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


Handles CheckBox1.CheckedChanged
If CheckBox1.Checked = True Then
TextBox1.Font = New Font(TextBox1.Font, FontStyle.Bold)
End If
If CheckBox1.Checked = False Then
TextBox1.Font = New Font(TextBox1.Font, FontStyle.Regular)
End If
End Sub

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


Handles CheckBox2.CheckedChanged
If CheckBox2.Checked = True Then
TextBox1.Font = New Font(TextBox1.Font, FontStyle.Italic)
End If
If CheckBox2.Checked = False Then
TextBox1.Font = New Font(TextBox1.Font, FontStyle.Regular)
End If

21
End Sub

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


Handles CheckBox3.CheckedChanged
If CheckBox3.Checked = True Then
TextBox1.Font = New Font(TextBox1.Font, FontStyle.Underline)
End If
If CheckBox3.Checked = False Then
TextBox1.Font = New Font(TextBox1.Font, FontStyle.Regular)
End If
End Sub

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


Handles CheckBox4.CheckedChanged

If CheckBox4.Checked = True Then


TextBox1.Font = New Font(TextBox1.Font, FontStyle.Strikeout)
End If
If CheckBox4.Checked = False Then
TextBox1.Font = New Font(TextBox1.Font, FontStyle.Regular)
End If
End Sub

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


Handles CheckBox8.CheckedChanged
If CheckBox8.Checked = True Then
TextBox1.ForeColor = Color.Red
End If
If CheckBox8.Checked = False Then
TextBox1.ForeColor = Color.Black
End If
End Sub

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


Handles CheckBox7.CheckedChanged
If CheckBox7.Checked = True Then
TextBox1.ForeColor = Color.Green
End If
If CheckBox7.Checked = False Then
TextBox1.ForeColor = Color.Black
End If
End Sub

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


Handles CheckBox6.CheckedChanged

22
If CheckBox6.Checked = True Then
TextBox1.ForeColor = Color.Blue
End If
If CheckBox6.Checked = False Then
TextBox1.ForeColor = Color.Black
End If
End Sub

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


Handles CheckBox5.CheckedChanged
If CheckBox5.Checked = True Then
TextBox1.ForeColor = Color.Purple
End If
If CheckBox5.Checked = False Then
TextBox1.ForeColor = Color.Black
End If
End Sub

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


Handles CheckBox10.CheckedChanged
If CheckBox10.Checked = True Then
TextBox1.Font = New Font(TextBox1.Text, TextBox1.Font.Size + 2)
End If
End Sub

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


Handles CheckBox9.CheckedChanged
If CheckBox9.Checked = True Then
TextBox1.Font = New Font(TextBox1.Text, TextBox1.Font.Size – 2)
End If
End Sub
End Class

23
Output:-

24
Q.10) Design the form that calculate Addition, Multiplication,
division and Subtraction of two number.
Program :-

Public Class Form1

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
TextBox3.Text = TextBox1.Text – TextBox2.Text
End Sub

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


Handles Button3.Click
TextBox3.Text = TextBox1.Text * TextBox2.Text
End Sub

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


Handles Button4.Click
TextBox3.Text = TextBox1.Text / TextBox2.Text
End Sub
End Class

OUTPUT:-

25
26
Q.11) Design Simple Calculator.

Program :-
Public Class Form1
Dim val1, val2 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 Button2_Click(sender As Object, e As EventArgs) Handles


Button2.Click
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

27
Private Sub Button7_Click(sender As Object, e As EventArgs) Handles
Button7.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 Button11_Click(sender As Object, e As EventArgs) Handles


Button11.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

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


Button16.Click
TextBox1.Text = TextBox1.Text & 0
End Sub

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


Button5.Click
val1 = TextBox1.Text
TextBox1.Clear()
TextBox1.Focus()
sign = "-"
End Sub

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


Button9.Click
val1 = TextBox1.Text
TextBox1.Clear()
TextBox1.Focus()
sign = "*"
End Sub

28
Private Sub Button13_Click(sender As Object, e As EventArgs) Handles
Button13.Click
val1 = TextBox1.Text
TextBox1.Clear()
TextBox1.Focus()
sign = "/"
End Sub

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


Button14.Click
val2 = TextBox1.Text
If sign = "+" Then
TextBox1.Text = val1 + val2
ElseIf sign = "-" Then
TextBox1.Text = val1 - val2
ElseIf sign = "*" Then
TextBox1.Text = val1 * val2
Else
TextBox1.Text = val1 / val2
End If
End Sub

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


Button15.Click
TextBox1.Clear()
TextBox1.Focus()
End Sub

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


Button4.Click
val1 = TextBox1.Text
TextBox1.Clear()
TextBox1.Focus()
sign = "+"
End Sub
End Class

29
Output:-

30
Q.12) Design the form to input radius of a circle and find its circumference
and area.

Program :-
Public Class Form1

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


Handles Button1.Click
Dim Radius As Decimal = CInt(TextBox1.Text)
Dim Pi As Decimal = 3.14
TextBox2.Text = Pi * (Radius * Radius)
TextBox3.Text = 2 * (Pi * Radius)
End Sub

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


Handles Button2.Click
TextBox1.Clear()
TextBox2.Clear()
TextBox3.Clear()
End Sub
End Class

31
Output:-

32
Q.13) Design the form to input length in Centimeter and Convert it into meter.

Program :-
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs)
Handles Button1.Click
Dim Cm As Integer
Cm = CInt(TextBox1.Text)
TextBox2.Text = Cm / 100
End Sub

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


Handles Button2.Click
TextBox1.Text = ""
TextBox2.Text = ""
End Sub
End Class

33
Output:-

34
Q.14) Design the form to input temperature in Celsius and convert it into
Fahrenheit.

Program :-
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs)
Handles Button1.Click
Dim cel As Decimal
Dim Fran As Decimal
cel = CInt(TextBox1.Text)
Fran = (cel * (9 / 5)) + 32
TextBox2.Text = Fran
End Sub

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


Handles Button2.Click
TextBox1.Text = ""
TextBox2.Text = ""
End Sub
End Class

35
Output:-

36
Q.15) Design the form to input Principal amount, time, Rate and Calculate
Simple interest and compound interest show result information in
msgbox.

Program :-
Public Class Form1
Private Sub Panel1_Paint(sender As Object, e As PaintEventArgs) Handles
Panel1.Paint

End Sub

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


Button1.Click
Dim p, t As Integer
Dim r As Decimal
Dim Si As Decimal
p = CInt(TextBox1.Text)
t = CInt(TextBox2.Text)
r = CInt(TextBox3.Text)
Si = (p * r * t) / 100
MsgBox("Simple Interest : " & Si)
Dim Amount As Decimal
Dim CI As Decimal
Amount = p * (Math.Pow((1 + r / 100), t))
CI = Amount - p
MsgBox("Compound Interest : " & CI)
End Sub

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


Button2.Click
TextBox1.Text = ""

37
TextBox2.Text = ""
TextBox3.Text = ""
End Sub
End Class

Output:-

38
Q.16) Design the form and write a program to sort array element in
ascending order.

Program :-
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
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

39
End If
Next
Next
ListBox1.Items.Clear()
For i = 0 To arr.Count - 1
ListBox1.Items.Add(arr(i))
Next
End Sub
End Class

Output:-

40
Q.17) Design the form and write a program to insert an element in an
Array.
Program :-
Public Class Form1
Dim arr(5) As Integer
Dim i As Integer = 0
Private Sub Button1_Click(sender As Object, e As
EventArgs) Handles Button1.Click
If i < arr.Count - 1 Then
arr(i) = CInt(TextBox1.Text)
ListBox1.Items.Add(arr(i))
i += 1
Else
MsgBox("Array is Full Can't Add More
Element!!")
End If
End Sub
End Class

41
Output:-

42
Q.18) Design the form and write a program to delete an element from an
array at specified position.

Program :-
Public Class Form1
Dim arr() As Integer = {1, 2, 3, 4, 5}
Private Sub Button1_Click(sender As Object, e As
EventArgs) Handles Button1.Click
Dim ArrEnd As Integer = arr.Length - 1
Dim i As Integer = 0
Dim Pos As Integer = CInt(TextBox1.Text)
While i <> Pos
i += 1
End While
While i <> arr.Count - 1
arr(i) = arr(i + 1)
i += 1
End While
ListBox1.Items.Clear()
ReDim Preserve arr(arr.Length - 2)
Dim j As Integer = 0
For j = 0 To arr.Length - 1
ListBox1.Items.Add(arr(j))
Next
End Sub

43
Private Sub Form1_Load(sender As Object, e As
EventArgs) Handles MyBase.Load
Dim i As Integer = 0
ListBox1.Items.Clear()
For i = 0 To arr.Length - 1
ListBox1.Items.Add(arr(i))
Next
End Sub
End Class

Output:-

44
Q.19) Design the from and write a program to print all unique element in
the array.

Program :-
Public Class Form1
Dim arr() As Integer = {9, 9, 8, 1, 3, 6, 9, 7, 1, 2}

Private Sub Button1_Click(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

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
Next
If flag = False Then

45
ListBox2.Items.Add(arr(i))
End If
Next
End Sub
End Class

Output:-

46
Q.20) Design a form to check whether a number is prime Or not using
input box and msgbox.
Program :-
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs)
Handles Button1.Click
Dim i As Integer
Dim num As Integer = CInt(TextBox1.Text)
Dim f As Boolean = False
For i = 2 To num - 1
If num Mod i = 0 Then
TextBox2.Text = "Not a Prime"
f = True
Exit For
End If
Next
If f = False Then
TextBox2.Text = "Prime Number"
End If
End Sub
End Class

47
Output:-

48
Q.21) Write a program to print Fibonacci series up to n terms.

Program :-
Public Class Form1
Private Sub Button2_Click(sender As Object, e As EventArgs)
Handles Button2.Click
TextBox1.Text = ""
ListBox1.Items.Clear()
End Sub
Public Function GetFib(ByVal n As Integer) As Integer
ListBox1.Items.Clear()
Dim a, b, c As Integer
Dim i As Integer
a = 0
b = 1
ListBox1.Items.Add(a)
ListBox1.Items.Add(b)
For i = 1 To n - 2
ListBox1.Items.Add(a + b)
c = a + b
a = b
b = c
n -= 1
Next

49
Return 0
End Function
Private Sub Button1_Click(sender As Object, e As EventArgs)
Handles Button1.Click
Dim n As Integer = CInt(TextBox1.Text)
GetFib(n)
End Sub
End Class

Output:-

50
Q.22) Design the following form when user clicks on Radio Button then select
Checkbox.

Program :-

Public Class Form1


Dim gen As Boolean = False
Private Sub RadioButton3_CheckedChanged(sender As Object, e
As EventArgs) Handles RadioButton3.CheckedChanged
If gen = True And RadioButton3.Checked = True Then
CheckBox1.Checked = True
CheckBox3.Checked = False
CheckBox2.Checked = False
End If
End Sub

Private Sub RadioButton1_CheckedChanged(sender As Object, e


As EventArgs) Handles RadioButton1.CheckedChanged
gen = True
End Sub

Private Sub RadioButton2_CheckedChanged(sender As Object, e


As EventArgs) Handles RadioButton2.CheckedChanged
gen = True
End Sub

Private Sub RadioButton4_CheckedChanged(sender As Object, e


As EventArgs) Handles RadioButton4.CheckedChanged

51
If gen = True And RadioButton4.Checked = True Then
CheckBox1.Checked = False
CheckBox3.Checked = False
CheckBox2.Checked = True
End If
End Sub

Private Sub RadioButton5_CheckedChanged(sender As Object, e


As EventArgs) Handles RadioButton5.CheckedChanged
If gen = True And RadioButton5.Checked = True Then
CheckBox1.Checked = False
CheckBox3.Checked = True
CheckBox2.Checked = False
End If
End Sub

End Class

Output:-

52
Q.23) Design the Digital watch using Timer Control.

Program :-
Public Class Form1

Dim hh, mm, ss As Integer

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


Handles Button3.Click
Label1.Text = "23"
Label3.Text = "59"
Label5.Text = "00"
End Sub

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


Handles Timer1.Tick
hh = Val(Label1.Text)
mm = Val(Label3.Text)
ss = Val(Label5.Text)
ss = ss + 1
If ss = 60 Then
ss = 0
mm = mm + 1

53
End If
If mm = 60 Then
mm = 0
hh = hh + 1
End If
If hh = 24 Then
hh = 1
End If
Label1.Text = Format(hh, "00")
Label3.Text = Format(mm, "00")
Label5.Text = Format(ss, "00")
End Sub

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


Handles Button2.Click
Timer1.Enabled = False
End Sub

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


Handles Button1.Click
Timer1.Enabled = True
End Sub
End Class

Output:-

54
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

Program:-

Public Class Form1

Private Sub HScrollBar1_Scroll(sender As Object, e


As ScrollEventArgs) Handles HScrollBar1.Scroll
Panel1.BackColor = Color.Red
End Sub

Private Sub HScrollBar2_Scroll(sender As Object, e


As ScrollEventArgs) Handles HScrollBar2.Scroll
Panel2.BackColor = Color.Green
End Sub

Private Sub HScrollBar3_Scroll(sender As Object, e


As ScrollEventArgs) Handles HScrollBar3.Scroll
Panel3.BackColor = Color.Blue
End Sub
End Class

55
OUTPUT:-

56
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.

Program:-

Public Class Form1

Private Sub VScrollBar1_Scroll(sender As Object, e


As ScrollEventArgs) Handles VScrollBar1.Scroll
Panel1.BackColor = Color.Red
End Sub

Private Sub VScrollBar2_Scroll(sender As Object, e


As ScrollEventArgs) Handles VScrollBar2.Scroll
Panel2.BackColor = Color.Green
End Sub

Private Sub VScrollBar3_Scroll(sender As Object, e


As ScrollEventArgs) Handles VScrollBar3.Scroll
Panel3.BackColor = Color.Blue
End Sub
End Class

57
OUTPUT:-

58
Q.26) Design the form with different controls.

Program :-
Public Class Form1
Dim msg As String
Dim accessories As String
Dim process As String
Dim Os As String
Private Sub Form1_Load(sender As Object, e As EventArgs)
Handles MyBase.Load

End Sub

Private Sub CheckBox1_CheckedChanged(sender As Object, e As


EventArgs) Handles CheckBox1.CheckedChanged

If CheckBox1.Checked = True Then


accessories = accessories + CheckBox1.Text & ","
ElseIf CheckBox1.Checked = False Then
accessories = accessories.Replace("Printer,", "")
End If
End Sub

Private Sub CheckBox2_CheckedChanged(sender As Object, e As


EventArgs) Handles CheckBox2.CheckedChanged
If CheckBox2.Checked = True Then

59
accessories = accessories + CheckBox2.Text & ","
ElseIf CheckBox2.Checked = False Then
accessories = accessories.Replace("Modem,", "")
End If
End Sub

Private Sub CheckBox4_CheckedChanged(sender As Object, e As


EventArgs) Handles CheckBox4.CheckedChanged

If CheckBox4.Checked = True Then


accessories = accessories + CheckBox4.Text & ","

ElseIf CheckBox4.Checked = False Then


accessories = accessories.Replace("Moniter,", "")
End If
End Sub

Private Sub CheckBox3_CheckedChanged(sender As Object, e As


EventArgs) Handles CheckBox3.CheckedChanged
If CheckBox3.Checked = True Then
accessories = accessories + CheckBox3.Text & ","
ElseIf CheckBox3.Checked = False Then
accessories = accessories.Replace("NIC,", "")
End If
End Sub

Private Sub RadioButton1_CheckedChanged(sender As Object, e


As EventArgs) Handles RadioButton1.CheckedChanged
If RadioButton1.Checked = True Then
process = "Pentium 1"
Else
process = ""
End If
End Sub

Private Sub RadioButton2_CheckedChanged(sender As Object, e


As EventArgs) Handles RadioButton2.CheckedChanged
If RadioButton2.Checked = True Then
process = "Pentium 2"

60
Else
process = ""
End If
End Sub

Private Sub RadioButton3_CheckedChanged(sender As Object, e


As EventArgs) Handles RadioButton3.CheckedChanged
If RadioButton3.Checked = True Then
process = "Pentium 3"
Else
process = ""
End If
End Sub

Private Sub RadioButton4_CheckedChanged(sender As Object, e


As EventArgs) Handles RadioButton4.CheckedChanged
If RadioButton4.Checked = True Then
Os = "Windows 98"
Else
Os = ""
End If
End Sub

Private Sub RadioButton6_CheckedChanged(sender As Object, e


As EventArgs) Handles RadioButton6.CheckedChanged
If RadioButton6.Checked = True Then
Os = "Windows NT"
Else
Os = ""
End If
End Sub

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


Handles Button1.Click
msg = "You selected a " & process & " With " & Os & "
And accesories " & accessories
TextBox1.Text = msg
End Sub

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

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


Handles Button2.Click
accessories = ""
msg = ""
process = ""
Os = ""
RadioButton1.Checked = False
RadioButton2.Checked = False
RadioButton3.Checked = False
RadioButton4.Checked = False
RadioButton6.Checked = False
CheckBox1.Checked = False
CheckBox2.Checked = False
CheckBox3.Checked = False
CheckBox4.Checked = False
TextBox1.Text = msg
End Sub
End Class

62
Output:-

63
Q.27) Write a program for exception handling of throwing an exception
when dividing by zero condition occur during arithmetic operation.
Program :-
Imports System

Module Program
Public Sub Divide(ByVal a As Integer, ByVal b As Integer)
Dim result As Decimal
Try
result = a / b
Catch ex As Exception
Console.WriteLine(" This IS Exception ---->>)
{0}", ex)
Console.ReadLine()
Finally
Console.WriteLine("Result : {0}", result)
Console.ReadLine()
End Try
End Sub

Sub Main(args As String())


Dim a As Integer = Console.ReadLine()
Dim b As Integer = Console.ReadLine()
Divide(a, b)
End Sub
End Module

Output:-

64
Q.28) WAP in vb.net such that throw a user define exception when
Temperature is
Zero

Program:-
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs)
Handles Button1.Click
Dim num As Integer = CInt(Label2.Text)
num += 1
Label2.Text = num
If num = 0 Then
MsgBox("Tempreture is 0 :-)", 48)
End If
End Sub

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


Handles Button2.Click
Dim num As Integer = CInt(Label2.Text)
num -= 1
Label2.Text = num
If num = 0 Then
MsgBox("Tempreture is 0 :-)", 48)
End If
End Sub
End Class

65
Output:-

66
Q.29) Design form that show the functionality of listbox

Program :-
Public Class Form1
Private Sub Button5_Click(sender As Object, e As EventArgs) Handles
Button5.Click
Dim item As String
item = InputBox("Enter Value : ")
ListBox1.Items.Add(item)
End Sub

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


Button6.Click
ListBox1.Items.Remove(ListBox1.SelectedItem)
End Sub

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


Button7.Click
ListBox1.Items.Clear()
ListBox2.Items.Clear()
End Sub

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


Button8.Click
ListBox1.Sorted = True
ListBox2.Sorted = True
End Sub

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


Button1.Click
If ListBox1.SelectedItem = "" Then
MsgBox("You did't select any item!!")

67
Else
ListBox2.Items.Add(ListBox1.SelectedItem)
ListBox1.Items.RemoveAt(ListBox1.SelectedIndex)
End If
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 Button3_Click(sender As Object, e As EventArgs) Handles


Button3.Click
If ListBox2.SelectedItem = "" Then
MsgBox("You did't select any item!!")
Else
ListBox1.Items.Add(ListBox2.SelectedItem)
ListBox2.Items.RemoveAt(ListBox2.SelectedIndex)
End If
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
End Class

Output:-

Add Value

68
Move >

All move

Remove value

69
Sort

70
Q.30) Write a vb.net program to show data in data Grid view.

Program:-

Public Class Form1

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


Handles Button1.Click
Me.DataGridView1.Rows.Add(TextBox1.Text, TextBox2.Text)
End Sub
End Class

71
OUTPUT:-

72
Q.31) Create following table Student(id,name,course,DOB,address)
Write vb.net application to
1. Add records
2. View all the records

Program:-
Imports System.Data
Imports System.Data.OleDb
Public Class Form1
Dim n As Integer
Sub Pross()
Dim con As New
OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data
Source=D:\DotNet\Q_31_Student.accdb")
con.Open()
Dim adp As New OleDbDataAdapter("select * from Student", con)
Dim ds As New DataSet
adp.Fill(ds, "Student")
n = ds.Tables("Student").Rows.Count
con.Close()
End Sub

73
Sub ShowGrid()
Dim con As New
OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data
Source=C:\Users\Anujay Sahay\AppData\Local\Temporary
Projects\WindowsApplication1\Student.accdb")
con.Open()
Dim adp As New OleDbDataAdapter("select * from Student_Table", con)
Dim ds As New DataSet
adp.Fill(ds, "Student_Table")
DataGridView1.DataSource = ds.Tables("Student_Table")
con.Close()
End Sub
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles
MyBase.Load
'TODO: This line of code loads data into the
'StudentDataSet.Student_Table' table. You can move, or remove it, as
needed.
Me.Student_TableTableAdapter.Fill(Me.StudentDataSet.Student_Table)

End Sub

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


Button2.Click
ShowGrid()
End Sub

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


Button1.Click
If TextBox1.Text = "" Or TextBox2.Text = "" Or TextBox3.Text = ""
Or TextBox4.Text = "" Then
MsgBox("Empty Fields !!")
Else
Dim con As New
OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data
Source=C:\Users\Anujay Sahay\AppData\Local\Temporary
Projects\WindowsApplication1\Student.accdb")
con.Open()
Dim cmd As New OleDbCommand()
cmd.Connection = con
cmd.CommandType = CommandType.Text
cmd.CommandText = "insert into Student_Table values ('" & n + 1
& "','" & TextBox1.Text & "','" & TextBox2.Text & "','" & TextBox3.Text &
"','" & TextBox4.Text & "')"
cmd.ExecuteNonQuery()

74
con.Close()
MsgBox("Record Saved Succesfully!!!")
End If
End Sub
End Class

OUTPUT :-

75
Q.32) Develop a project which display the student information in the
relevant fields from the database which already exists.

Program :-
Imports System.Data
Imports System.Data.OleDb
Public Class Form1
Dim con As New
OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data
Source=C:\Users\jatin\Documents\Q32_Database.accdb")
Dim Index As Integer = 0
Dim table As New DataTable()

Public Sub ShowData(Position As Integer)


Dim cmd As New OleDbCommand("select * from Student",
con)
Dim adp As New OleDbDataAdapter(cmd)
adp.Fill(table)
TextBox1.Text = table.Rows(Position)(0).ToString()
TextBox2.Text = table.Rows(Position)(1).ToString()
TextBox3.Text = table.Rows(Position)(2).ToString()
TextBox4.Text = table.Rows(Position)(3).ToString()
End Sub

76
Private Sub Button1_Click(sender As Object, e As EventArgs)
Handles Button1.Click
Index = 0
ShowData(Index)
End Sub

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


Handles Button2.Click
If Index = table.Rows.Count - 1 Then
MsgBox("Last Record Reached!!!")
Else
Index += 1
ShowData(Index)
End If
End Sub

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


Handles Button3.Click
If Index <> 0 Then
Index -= 1
ShowData(Index)
Else
MsgBox("First Record Reached!!")
End If
End Sub

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


Handles Button4.Click
Index = 0
Index = table.Rows.Count - 1
ShowData(Index)
End Sub

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


Handles Button5.Click
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""

77
con.Close()
End Sub
End Class

Output:--

78
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.

Program :-
Imports System
Module Module1
Structure Student
Dim name As String
Dim roll As Integer
Dim NameOfSub() As String
Dim Marks() As Integer
Sub GetData()
Console.WriteLine("Enter Student Name : ")
name = Console.ReadLine()
Console.WriteLine("Enter Roll Num : ")
roll = Console.ReadLine()
ReDim Preserve NameOfSub(2)
ReDim Preserve Marks(2)
Dim i As Integer
For i = 0 To NameOfSub.Length - 1
Console.WriteLine("Enter Subject " & i + 1 & " : ")
Dim subName As String = CStr(Console.ReadLine())
NameOfSub(i) = subName
Next
For i = 0 To Marks.Length - 1
Console.WriteLine("Enter Marks of Sub " & i + 1 & " : ")
Marks(i) = Console.ReadLine()
Next
End Sub
Sub Print()
Console.WriteLine("Student Name : " & name)
Console.ReadLine()
Console.WriteLine("Student Roll : " & roll)
Console.ReadLine()
Dim i As Integer
For i = 0 To NameOfSub.Length - 1
Console.WriteLine("Subjects : " & NameOfSub(i) & " ")
Console.ReadLine()
Next
For i = 0 To Marks.Length - 1
Console.WriteLine("Marks Of " & NameOfSub(i) & " : " &
Marks(i) & " ")

79
Console.ReadLine()
Next
End Sub
End Structure
Sub Main()
Dim st As New Student
st.GetData()
st.Print()
End Sub
End Module

OUTPUT:-

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.

Program :-

Public Class Form1

Public Class Calculate

Public Function Area(ByVal r As Decimal) As Decimal


'area of circle
Return (3.14 * r * r)
End Function

Public Function Area(ByVal val As Decimal, ByVal b As


Decimal, ByVal h As Decimal) As Decimal
'area of triangle
Return (val * b * h)
End Function

Public Function Area(ByVal i As Decimal, ByVal b As


Decimal) As Decimal
'area of rectangle
Return (i * b)
End Function

End Class

81
Dim b As Decimal, r As Decimal, i As Decimal, h As Decimal
Dim val As Decimal = 0.5
Dim ch As Integer

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


Handles Button3.Click
Dim obj As New Calculate()
i = InputBox("Enter The Value of l")
b = InputBox("Enter The Value of b")
TextBox1.Text = obj.Area(i, b)
End Sub

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


Handles Button1.Click
Dim obj As New Calculate()
r = InputBox("Enter The Value of R")
TextBox1.Text = obj.Area(r)
End Sub

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


Handles Button2.Click
Dim obj As New Calculate()
b = InputBox("Enter The Value of b")
h = InputBox("Enter The Value of h")
TextBox1.Text = obj.Area(val, b, h)
End Sub

End Class

82
Output:-

83
84
Q.35) WAP to check whether a given number is neon or not using user
define function.

Program :-
Public Class Form1

Public Function CheckNeon(ByVal Num As Integer) As Boolean


Dim Square As Integer = Num * Num
Dim DummySquare = Square
Dim NewNumber As Integer = 0
While (DummySquare > 0)
NewNumber = NewNumber + DummySquare Mod 10
DummySquare = DummySquare \ 10
End While
NewNumber = CInt(NewNumber)
Num = CInt(Num)
If Num = NewNumber Then
Return True
Else
Return False
End If

End Function

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


Handles Button1.Click
Dim Num As Integer = TextBox1.Text
Dim Ans As Boolean = CheckNeon(Num)
TextBox2.Text = Ans

85
End Sub

End Class

Output:-

86
Q.36) WAP to check whether a given number is Niven or not using procedure.

Program :-
Public Class Form1

Public Sub CheckNiven(ByVal Num As Integer)


Dim Square As Integer = Num * Num
Dim DummySquare = Square
Dim NewNumber As Integer = 0
If (Num < 9) Then
TextBox2.Text = True
NewNumber = Num
Else
While (DummySquare > 0)
NewNumber = NewNumber + DummySquare Mod 10
DummySquare = DummySquare \ 10
End While
End If

NewNumber = CInt(NewNumber)
Num = CInt(Num)
If Num Mod NewNumber = 0 Then
TextBox2.Text = True
Else
TextBox2.Text = False
End If

End Sub

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


Handles Button1.Click
Dim Num As Integer = TextBox1.Text

87
CheckNiven(Num)
End Sub

End Class

Output:--

88
37. WAP to check whether a given number is Duck number or not .

Program :-
Public Class Form1
Private Sub Label2_Click(sender As Object, e As EventArgs)
Handles Label2.Click

End Sub

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


Handles Button1.Click
Dim Num As String
Num = TextBox1.Text

If Num.StartsWith("0") Then
TextBox2.Text = False
ElseIf Num.Contains("0") Then
TextBox2.Text = True
Else
TextBox2.Text = False
End If

End Sub
End Class

89
Output:-

90
Q.38) WAP to check whether a given number is Spy number or not .

Program :-
Public Class Form1
Private Sub Button1_Click_1(sender As Object, e As
EventArgs) Handles Button1.Click
Dim Num As Integer
Num = TextBox1.Text
Dim Sum As Integer = 0
Dim Mul As Integer = 1
Dim Remain As Integer
Dim DummyNum As Integer = Num

While (DummyNum <> 0)


Remain = DummyNum Mod 10
Sum = Sum + Remain
Mul = Mul * Remain
DummyNum = DummyNum \ 10
End While

If Sum = Mul Then


MsgBox("Num is Spy Number : " & Num)
Else
MsgBox("Num is not a Spy Number : " & Num)
End If

End Sub
End Class

91
Output:-

92
Q.39) Write a program to find first and last digit of any number.
Program :-
Public Class Form1
Private Sub Button1_Click_1(sender As Object, e As
EventArgs) Handles Button1.Click
Dim Num As Integer
Console.WriteLine("Enter The Value of Num")
Num = Console.ReadLine()
Dim NewNum As Integer = Num
Dim First As Integer
Dim Last As Integer
Last = NewNum Mod 10
NewNum = NewNum \ 10
Dim remain As Integer
While (NewNum <> 0)
remain = NewNum Mod 10
NewNum = NewNum \ 10
End While
First = remain
Console.WriteLine("First Digit of Num : " & First & " Last Digit of
Num : " & Last)
End Sub
End Class

Output:-

93
Q.40) Write a program to enter any number and print its reverse.
Program :-
Public Class Form1
Private Sub Button1_Click_1(sender As Object, e As
EventArgs) Handles Button1.Click
Dim Num As Integer
Num = TextBox1.Text
Dim Remain As Integer
Dim Reverse As Integer = 0
Dim DummyNum As Integer = Num
While (DummyNum <> 0)
Remain = DummyNum Mod 10
Reverse = Reverse * 10 + Remain
DummyNum = DummyNum \ 10
End While

MsgBox("Num is " & Num & " And Its Reverse is " &
Reverse)
End Sub
End Class

Output:-

94
Q.41) WAP to check whether a given number is Armstrong number or not.

Program :-

Public Class Form1


Private Sub Button1_Click_1(sender As Object, e As
EventArgs) Handles Button1.Click
Dim Num As Integer
Num = TextBox1.Text
Dim Sum As Integer = 0
Dim NewNum As Integer = Num
Dim Remain As Integer
While (NewNum <> 0)
Remain = NewNum Mod 10
Sum = Sum + Remain * Remain * Remain
NewNum = NewNum \ 10
End While

If Sum = Num Then


MsgBox("Both The " & Num & " And " & Sum & " Is Same
So its is an Armstrong Number")
Else
MsgBox("Both The " & Num & " And " & Sum & " Is Not
Same So its is Not an Armstrong Number")
End If

End Sub
End Class

95
Output:-

96
Q.42) WAP to enter any number and check whether the no. is palindrome
or not.

Program :-
Public Class Form1
Private Sub Button1_Click_1(sender As Object, e As
EventArgs) Handles Button1.Click
Dim Num As Integer
Num = TextBox1.Text
Dim DummyNum As Integer = Num
Dim Rev As Integer = 0
Dim Remain As Integer

While (DummyNum > 0)


Remain = DummyNum Mod 10
Rev = Rev * 10 + Remain
DummyNum = DummyNum \ 10
End While

If Num = Rev Then


MsgBox("YES! It is a Palindrome")
Else
MsgBox("NO! It is Not a Palindrome")
End If
End Sub
End Class

97
Output:-

98
Q.43) Write a Program to calculate factorial of a number using user define
procedure.

Program:-
Public Class Form1
Private Sub Button1_Click_1(sender As Object, e As
EventArgs) Handles Button1.Click
Dim i, n, F As Integer
F = 1
n = TextBox1.Text
For i = 1 To n
F = F * i
Next
MsgBox("Factorial of " & n & " is " & F)
End Sub

End Class

OUTPUT:-

99
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.

PROGRAM :-

Imports System
Imports System.Runtime.CompilerServices

Module Program
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

100
Class cylinder
Inherits sphere
Sub display2(ByVal h1 As Integer)
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:--

101

You might also like