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.
15 Design the form to input Principal amount, Time, Rate and calculate
Simple
Interest and compound interest show result information in msgbox.
16 Design the form and write a program to sort array element in ascending
Order
17 Design the form and write a program to insert an element in an array.
18 Design the form and write a program to delete an element from an
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
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.
34 Write a class having name Calculate that uses static overloaded 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 user define
function.
36 WAP to check whether a given number is Niven or not using procedure.
42 WAP to enter any number and check whether the no. is palindrome or
not
43 WAP to calculate factorial of a number using user define procedure.
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.
CONSOLE APPLICATION
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
Output:-
Output:--
Q.
Coding:-
Imports System
Module Leap_Year
Sub Main()
Dim year As Integer = 0
End Module
Output:-
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:-
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)
Else
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:-
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:--
Bold
Italic Underline
Increase font size
Decrease font size
Font color
Program Code:--
Public Class Form1
End If
End Sub End
Class
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
TextBox2.Text = ""
TextBox3.Text = ""
End Sub End
Class
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
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
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}
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
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
End If
End Sub
End Class
Output:--
Program Code:--
Public Class Form1
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
End If
End Sub
Output:--
Output:--
28. WAP in vb.net such that throw a user define exception when
Temperature is
Zero
Output:-
Class
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:--
1. Add records
2. View all the records
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()
Index -= 1
ShowData(Index)
Else
MsgBox("First Record Reached!!")
End If
End Sub
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
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
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
End Sub End
Class
Output:--
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:--
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 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:--
Program Code:--
Imports System
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
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:--