Professional Documents
Culture Documents
Dot Net Practical File 2023
Dot Net Practical File 2023
INDEX
S. No. Name of Program Page Sign
no.
1 Write a program to find maximum between three numbers. 5
15 Design the form to input Principal amount, Time, Rate and calculate 29-30
Simple
Interest and compound interest show result information in msgbox.
16 Design the form and write a program to sort array element in ascending 31-32
Order
17 Design the form and write a program to insert an element in an array. 33
18 Design the form and write a program to delete an element from an 34-35
24 Design the following form using horizontal scrollbar. In this, when user 45
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 user 46-47
click on particular scrollbar then back color of shape will be changed
to Red, Green &Blue color
28 WAP in vb.net such that throw a user define exception when 53-54
Temperature is zero.
32 Develop a project which displays the student information in the relevant 61-63
fields from the database which already exists.
33 Define structure student. Structure student has data members for storing 63-64
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 function 65-68
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 user define 68
function.
36 WAP to check whether a given number is Niven or not using procedure. 69-70
42 WAP to enter any number and check whether the no. is palindrome or 76-77
not
43 WAP to calculate factorial of a number using user define procedure. 77
44 Create a class circle with data member radius; provide member function to 78-79
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.
CONSOLE APPLICATION
Coding:-
Module maximum_number
Sub Main()
Dim a, b, c As Integer
Console.Write("Enter the a,b & c number = ")
a = CInt(Console.ReadLine()) b =
CInt(Console.ReadLine()) c =
CInt(Console.ReadLine())
If a > b Then
If a > c Then
Console.WriteLine("maximum number = " + a.ToString())
Else
Console.WriteLine("maximum number = " + c.ToString())
End If
Else
If b > c Then
Console.WriteLine("maximum number = " + b.ToString())
Else
Console.WriteLine("maximum number = " + c.ToString())
End If
End If
Console.ReadLine()
End Sub End
Module
Output:-
Program Code:--
Imports System
Module Program
Sub Main(args As String())
Dim n As Integer
Console.WriteLine("Enter value of n:-")
n = Console.ReadLine() If n >= 0 Then
If n = 0 Then
Console.WriteLine("n is zero : " & n)
Console.ReadLine()
Else
Console.WriteLine("n is Positive : " & n)
Console.ReadLine()
End If
Else
Console.WriteLine("n is Negative : " & n)
Console.ReadLine()
End If
End Sub
End Module
Output:--
Coding:-
Imports System
Module Leap_Year
Sub Main()
Dim year As Integer = 0
year = Integer.Parse(Console.ReadLine())
If ((year Mod 4 = 0) AndAlso (year Mod 100 <> 0)) OrElse ((year Mod 4 = 0)
AndAlso (year Mod 100 = 0) AndAlso (year Mod 400 = 0)) Then
Console.WriteLine("Entered year is leap year")
Else
Console.WriteLine("Entered year is not leap year")
End If
End Sub
End Module
Output:-
Coding:-
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 Else
Console.WriteLine("No! It is Not an Alphabet : " & a)
Console.ReadLine()
End Select
End Sub
End Module
Output:-
Coding:-
Imports System
Module Program
Sub main()
Dim a, b, c, r1, r2 As Single
Console.WriteLine("** Program to find all Roots of a Quadration Eqation **")
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
End Sub
End Module
Output:-
Program Code:--
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
Label9.Text = " D "
Case 40 To 59
Label9.Text = " E "
Case 0 To 39
Label9.Text = " F "
End Select
End Sub
Output:--
Program Code:---
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
Output:---
Program Code:--
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles
Button1.Click
If TextBox1.Text = "" Or TextBox2.Text = "" Then
MsgBox("Please Enter Username & Password")
ElseIf TextBox1.Text = "Admin" And TextBox2.Text = "Password" Then
MsgBox("Login Success")
Else
MsgBox("Wrong Username & Password")
TextBox1.Text = ""
TextBox2.Text = ""
End If
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles
Button2.Click
End
End Sub
End Class
Output:--
Program Code:--
Public Class Form1
Output:--
Program Code:---
Public Class Form1
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles
Button3.Click
Dim a As Integer
Dim b As Integer a =
CInt(TextBox1.Text) b =
CInt(TextBox2.Text)
TextBox3.Text = a * b
End Sub
CInt(TextBox1.Text) b =
CInt(TextBox2.Text)
TextBox3.Text = a / b
End Sub
Output:--
Program Code:--
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
End Sub
Output:-
12. Design the form to input radius of a circle and find its
circumference and area.
Program Code:--
Public Class Form1
Output:--
Program Code:--
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
Output:--
14. design the form to input temperature in Celsius and convert it into
Fahrenheit.
Program Code:--
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
Output:--
15. Design the form to input Principal amount, time, Rate and Calculate
Program Code:--
Public Class Form1
Private Sub Panel1_Paint(sender As Object, e As PaintEventArgs) Handles
Panel1.Paint
End Sub
Output:--
16. Design the form and write a program to sort array element in
ascending order.
Program 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
ArrayBox.Items.Clear()
Dim i As Integer = 0
For i = 0 To arr.Count - 1
ArrayBox.Items.Add(arr(i))
Next
End Sub
Output:--
Program Code:--
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)
ArrayBox.Items.Add(arr(i)) i
+= 1
Else
MsgBox("Array is Full Can't Add More Element!!")
End If
End Sub End
Class
Output:--
18. Design the form and write a program to delete an element from an
array at specified position.
Program Code:--
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
Output:--
19. Design the from and write a program to print all unique element in
the array.
Program Code:--
Public Class Form1
Dim arr() As Integer = {9, 9, 8, 1, 3, 6, 9, 7, 1, 2}
Output:--
20. Design a form to check whether a number is prime Or not using input
box and msgbox.
Program Code:--
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
Output:--
Program Code:--
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
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:--
22. Design the following form when user clicks on Radio Button then select
Checkbox.
Program Code:--
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
CheckBox2.Checked = False
End If
End Sub
End Class
Output:--
Program Code:--
Public Class Form1
Output:--
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.
Output:--
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 Code:--
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
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
Output:-- red
Green
Blue
Program Code:--
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
CheckBox3.CheckedChanged
If CheckBox3.Checked = True Then
accessories = accessories + CheckBox3.Text & ","
ElseIf CheckBox3.Checked = False Then
accessories = accessories.Replace("NIC,", "")
End If
End Sub
Output:--
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
Output:--
28. WAP in vb.net such that throw a user define exception when
Temperature is
Zero
Output:-
End Sub
Output:-
Add Value
Move >
All move
Remove value
Sort
Program code:-
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
Output:--
Program Code:-
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
Sub ShowGrid()
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")
DataGridView1.DataSource = ds.Tables("Student")
con.Close()
End Sub
Private Sub Button1_Click(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
Pross()
Dim con As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data
Source=D:\DotNet\Q_31_Student.accdb")
con.Open()
Dim cmd As New OleDbCommand()
cmd.Connection = con cmd.CommandType
= CommandType.Text
cmd.CommandText = "insert into Student values (" & n + 1 & ",'" &
TextBox1.Text & "','" & TextBox2.Text & "','" & TextBox3.Text & "','" &
TextBox4.Text & "')" cmd.ExecuteNonQuery()
con.Close()
MsgBox("Record Saved Succesfully!!!")
End If
End Sub
End Class
Output:--
Program Code:--
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()
Output:--
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 Code:--
Imports System
Module Program
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.WriteLine("Student Roll : " & roll)
Dim i As Integer
For i = 0 To NameOfSub.Length - 1
Console.WriteLine("Subjects : " & NameOfSub(i) & " ")
Next
For i = 0 To Marks.Length - 1
Console.WriteLine("Marks Of " & NameOfSub(i) & " : " & Marks(i) & "
")
Next
End Sub
End Structure
Sub Main()
Dim st As New Student
st.GetData() st.Print()
End Sub
End Module
Output:--
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 Code:--
End Class
Button1.Click
Dim obj As New Calculate() r
= InputBox("Enter The Value of R")
TextBox1.Text = obj.Area(r)
End Sub
Output:--
Circle
Triangle
Rectangle
35. WAP to check whether a given number is neon or not using user
define function.
Program Code:---
Public Class Form1
End Function
End
Class
Output:---
Program Code:--
Public Class Form1
NewNumber = CInt(NewNumber)
Num = CInt(Num)
If Num Mod NewNumber = 0 Then
TextBox2.Text = True
Else
TextBox2.Text = False
End If
End Sub
Output:--
Program Code:--
Public Class Form1
Private Sub Label2_Click(sender As Object, e As EventArgs) Handles Label2.Click
End Sub
If Num.StartsWith("0") Then
TextBox2.Text = False
ElseIf Num.Contains("0") Then
TextBox2.Text = True
Else
TextBox2.Text = False
End If
Output:--
Module Program
Sub Main(args As String())
Console.WriteLine("Enter The value of Num : ")
Dim Num As Integer = Console.ReadLine()
Dim Sum As Integer = 0
Dim Mul As Integer = 1
Dim Remain As Integer
Dim DummyNum As Integer = Num
Output:--
39. Write a program to find first and last digit of any number.
Program Code:--
Imports System
Module Program
Sub Main(args As String())
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 Module
Output:--
40. Write a program to enter any number and print its reverse.
Program Code:--
Imports System
Module Program
Sub Main(args As String())
Dim Num As Integer
Console.WriteLine("Enter Value Of Num : ")
Num = Console.ReadLine()
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
Console.WriteLine("Num is " & Num & " And Its Reverse is " & Reverse)
End Sub
End Module
Output:--
Module Program
Sub Main(args As String())
Dim Num As Integer
Console.WriteLine("Enter The Value Of Num : ")
Num = Console.ReadLine()
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
Output:--
42. WAP to enter any number and check whether the no. is palindrome or
not.
Program Code:--
Imports System
Module Program
Sub Main(args As String())
Dim Num As Integer
Console.WriteLine("Enter The Value Of Num : ")
Num = Console.ReadLine()
Dim DummyNum As Integer = Num
Dim Rev As Integer = 0
Dim Remain As Integer
Output:--
Module Factorial
Sub main()
Dim i, n, F As Integer
F = 1
System.Console.WriteLine("Enter Number to find Factorial:-")
n = System.Console.ReadLine()
For i = 1 To n
F = F * i
Next
System.Console.WriteLine("Factorial of " & n & " is " & F)
System.Console.ReadLine()
End Sub
End Module
Output:--
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 Code:--
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
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:--