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

Practical

The document contains details about a student named Yash Jugalkishor Paigware including their class, subject, and roll number. It then provides the code and output for 10 programming questions/exercises in VB.NET covering topics like calculating digit sums and reversals, factorials, checking even/odd numbers, validating usernames and passwords, adding matrices, calculating employee salary details, defining classes for boxes and calculating volumes, demonstrating single inheritance, and creating a data-bound windows form to retrieve and navigate database records. The questions cover basic concepts like algorithms, flowcharts, console and windows forms applications, classes, inheritance, and ADO.NET data access. The code provided implements the described logic to solve each problem

Uploaded by

Yash
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
58 views

Practical

The document contains details about a student named Yash Jugalkishor Paigware including their class, subject, and roll number. It then provides the code and output for 10 programming questions/exercises in VB.NET covering topics like calculating digit sums and reversals, factorials, checking even/odd numbers, validating usernames and passwords, adding matrices, calculating employee salary details, defining classes for boxes and calculating volumes, demonstrating single inheritance, and creating a data-bound windows form to retrieve and navigate database records. The questions cover basic concepts like algorithms, flowcharts, console and windows forms applications, classes, inheritance, and ADO.NET data access. The code provided implements the described logic to solve each problem

Uploaded by

Yash
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 14

NAME:- YASH JUGALKISHOR PAIGWARE

CLASS:- BCCA-2nd (Sem-IV)


SUBJECT:- VB.Net
Roll Number:- 81

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:

Enter any no.:


345
Sum of digits=12
Counting of digits=3
Reverse of the number=543
Q.2) Write an algorithm, draw a flowchart and develop a VB.NET windows
application to print factorial of given number.
CODE:
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs)
Handles Button1.Click
Dim n, f, i As Integer
f = 1
n = Val(TextBox1.Text)
For i = 1 To n
f = f * i
Next
MsgBox("Factorial is : " & f)
End Sub
End Class

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.Write(c(i, j) & " ")


Next j

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

Public Sub setBreath(ByVal bre As Double)


breath = bre
End Sub

Public Sub setHeight(ByVal hei As Double)


height = hei
End Sub

Public Function getVolume() As Double


Return length * breath * height
End Function
End Class

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

Console.WriteLine("Id : Sub Main()


{0}", id) Dim S As New
StudentResultInfo()
Console.WriteLine("Name :
{0}", name) S.SetInfo(101, "Yash",
End Sub 452, 90.4, "A")
End Class S.PrintInfo()
End Sub
Class StudentResultInfo End Module
Inherits PersonalInfo
Dim marks As Integer OUTPUT:
Dim per As Double Id : 101
Dim grade As String
Name : Yash
Public Sub SetInfo(ByVal
i As Integer, ByVal n As String, Marks : 452
ByVal m As Integer, ByVal p As Per : 90.4
Double, ByVal g As String)
SetPersonalInfo(i, Grade : A
n)
marks = m
Q.9) Write an algorithm, draw a flowchart and develop a VB.NET windows
application to create data bound control for retrieving the data from database.
CODE:
Imports System.Data.OleDb
Public Class Form1
Dim con As New OleDb.OleDbConnection
Dim inc, maxrows As Integer
Dim ds As New DataSet
Dim da As OleDb.OleDbDataAdapter
Dim cb As New OleDb.OleDbCommandBuilder(da)
Private Sub Form1_Load(By Val sender As System.Object,ByVal e As
System.EventArgs)Handels MyBase.Load
Con.ConnectionString=”Provider=Microsoft.ACE.OLEDB.12.0;”
da=New OleDb.OleDbDataAdapter(“select* from stud”, con)da.Fill(ds,”stud”)
maxrows=ds.Tables(“stud”).Rows.Count
inc = 0
TextBox1.Text=ds.Tables(“stud”).Rows(inc).Item(0)
TextBox2.Text=ds.Tables(“stud”).Rows(inc).Item(1)
TextBox3.Text=ds.Tables(“stud”).Rows(inc).Item(2)
TextBox4.Text=ds.Tables(“stud”).Rows(inc).Item(3)
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs)Handles Button2.Click
If inc <>maxrows- 1 Then
inc=inc +1
navigateRecords()
Else
MsgBox(“No More Rows”)
End If
End Sub
Private Sub Button3_Click(sender As Object, e As EventArgs)Handles Button3.Click
If inc> 0 Then
Inc = inc- 1
navigateRecords()
Else
MsgBox(“First Record”)
End If
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs)Handles Button1.Click
If inc<> 0 Then
Inc = 0
navigateRecords()
End If
End Sub
Private Sub Button4_Click(sender As Object, e As EventArgs)Handles Button4.Click
If inc<>maxrows – 1Then
Inc = maxrows -1
navigateRecords()
End If
End Sub
Private Sub navigateRecords()
TextBox1.Text=ds.Tables(“stud”).Rows(inc).Item(0)
TextBox2.Text=ds.Tables(“stud”).Rows(inc).Item(1)
TextBox3.Text=ds.Tables(“stud”).Rows(inc).Item(2)
TextBox4.Text=ds.Tables(“stud”).Rows(inc).Item(3)
End Sub
End Class
OUTPUT:
Q.10) Write an algorithm, draw a flowchart and develop a VB.NET windows
application access data in a DataGridView control using code.
CODE:
Imports System.Data.OleDb
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs)Handles Button1.Click
Dim connectionString As String=”Provider=Microsoft.ACE.OLEDB.12.0;”
Dim connection As New OleDbConnection(connectionString)
Dim dataadapter As New OleDbDataAdapter(sql,connection)
Dim ds As New DataSet()
Connection.Open()
Dataadapter.Fill(ds,”stud”)
connection.Close()
DataGridView1.DataSource=ds
DataGridView1.DataMember=”stud”
End Sub
End Class
OUTPUT:

You might also like