Content-Length: 3123675 | pFad | https://www.scribd.com/document/662637379/VB-Net-Practical
5Practical
Practical
Practical
Q.1) Write and algorithm, draw a flowchart and develop a VB.NET console
application to calculate
i) Sum of Digit ii) Counting of digit iii) Reverse of a number
CODE:
Module Program1
Sub Main()
Dim n, r, sum, c1, rev As Integer
sum = 0
c1 = 0
rev = 0
Console.WriteLine("Enter any no.:")
n = Console.ReadLine()
While (n <> 0)
r = n Mod 10
sum = sum + r
c1 = c1 + 1
rev = (rev * 10) + r
n = n / 10
End While
Console.WriteLine("Sum of digits={0}", sum)
Console.WriteLine("Counting of digits={0}", c1)
Console.WriteLine("Reverse of the number={0}", rev)
Console.ReadLine()
End Sub
End Module
OUTPUT:
OUTPUT:
Q.3) Write an algorithm, draw a flowchart and develop a VB.NET Windows
application to check entered number is Even or Odd.
CODE:
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs)
Handles Button1.Click
Dim n As Integer
n = Val(TextBox1.Text)
If n Mod 2 = 0 Then
MsgBox(n & "" & " is an even number")
Else
MsgBox(n & " " & "is an odd number")
End If
End Sub
End Class
OUTPUT:
Q.4) Write an algorithm, draw a flowchart and develop a VB.NET windows
application to check the user id and password is valid or not.
CODE:
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles
Button1.Click
If TextBox1.Text = "" And TextBox2.Text = "" Then
MsgBox("Username and password cannot be blank")
ElseIf TextBox1.Text = "Admin" And TextBox2.Text = "admin" Then
MsgBox("Login successful")
TextBox1.Text = ""
TextBox2.Text = ""
Else
MsgBox("Login Failed!!")
TextBox1.Text = ""
TextBox2.Text = ""
End If
End Sub
End Class
OUTPUT:
Q.5) Write an algorithm, draw a flowchart and develop a VB.NET application to
print addition of two matrices.
CODE:
Module Program OUTPUT:
Sub Main()
Dim i, j As Integer Enter Matrix A
Dim a(2, 2), b(2, 2), 1
c(2, 2) As Integer 2
Console.WriteLine("Enter 3
Matrix A") 4
For i = 0 To 2 5
6
For j = 0 To 2
7
a(i, j) =
8
Console.ReadLine()
9
Next j
Next i
Enter Matrix B
Console.WriteLine("Enter
11
Matrix B")
22
For i = 0 To 2 33
For j = 0 To 2 44
b(i, j) = 55
Console.ReadLine() 66
Next j 77
Next i 88
99
Console.WriteLine("Addition of
Matrices") Addition of Matrices
For i = 0 To 2 12 24 36
For j = 0 To 2
c(i, j) = a(i, 48 60 72
j) + b(i, j)
Next j 84 96 108
Next i
For i = 0 To 2
For j = 0 To 2
Console.WriteLine(vbCrLf)
Next i
Console.ReadKey()
End Sub
End Module
Q.6) Write an algorithm, draw a flowchart and develop a VB.NET windows
application to design Employee Salary sheet and calculate DA, HRA, TA, PF and
Net salary when click on Submit button.
CODE:
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles
Button1.Click
Dim bs, da, hra, ta, pf, nets
bs = Val(TextBox6.Text)
da = (5 / 100) * bs
TextBox1.Text = da
hra = (10 / 100) * bs
TextBox2.Text = hra
ta = (12 / 100) * bs
TextBox3.Text = ta
pf = (6 / 100) * bs
TextBox4.Text = pf
nets = (bs + da + hra + ta) - pf
MsgBox("Net Salary is:" & nets)
End Sub
End Class
OUTPUT:
Q.7) Write an algorithm, draw a flowchart and develop a VB.NET console
application to create class BOX having member variable as length, breath, height
and member function setlength(),setbreath(),setheight() for giving initial variable
to members and function getvolume() to calculate volume of box.
CODE:
Imports System
Module Program
Class Box
Public length As Double
Public breath As Double
Public height As Double
Public Sub setLength(ByVal len As Double)
length = len
End Sub
Sub Main()
Dim Box1 As Box = New Box()
Dim volume As Double = 0.0
Box1.setLength(6.0)
Box1.setBreath(7.0)
Box1.setHeight(5.0)
volume = Box1.getVolume()
Console.WriteLine(“Volume of Box1 : {0}”, volume)
Console.ReadKey()
End Sub
End Module
OUTPUT:
Volume of Box1 : 210
Q.8) Write an algorithm, draw a flowchart and develop a VB.NET console
application to demonstrate Single Inheritance.
CODE:
Imports System per = p
grade = g
Module Program End Sub
Class PersonalInfo Public Sub PrintInfo()
Dim id As Integer PrintPersonalInfo()
Dim name As String
Console.WriteLine("Marks :
Public Sub {0}", marks)
SetPersonalInfo(ByVal i As
Integer, ByVal n As String) Console.WriteLine("Per :
id = i {0}", per)
name = n
End Sub Console.WriteLine("Grade :
{0}", grade)
Public Sub End Sub
PrintPersonalInfo() End Class
Fetched URL: https://www.scribd.com/document/662637379/VB-Net-Practical
Alternative Proxies: