0% found this document useful (0 votes)
186 views14 pages

VB.NET Applications: Algorithms & Code Examples

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
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
186 views14 pages

VB.NET Applications: Algorithms & Code Examples

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
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

NAME:- YASH JUGALKISHOR PAIGWARE

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


SUBJECT:- [Link]
Roll Number:- 81

Q.1) Write and algorithm, draw a flowchart and develop a [Link] 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
[Link]("Enter any no.:")
n = [Link]()
While (n <> 0)
r = n Mod 10
sum = sum + r
c1 = c1 + 1
rev = (rev * 10) + r
n = n / 10
End While
[Link]("Sum of digits={0}", sum)
[Link]("Counting of digits={0}", c1)
[Link]("Reverse of the number={0}", rev)
[Link]()
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 [Link] windows
application to print factorial of given number.
CODE:
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs)
Handles [Link]
Dim n, f, i As Integer
f = 1
n = Val([Link])
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 [Link] 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 [Link]
Dim n As Integer
n = Val([Link])
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 [Link] 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
[Link]
If [Link] = "" And [Link] = "" Then
MsgBox("Username and password cannot be blank")
ElseIf [Link] = "Admin" And [Link] = "admin" Then
MsgBox("Login successful")
[Link] = ""
[Link] = ""
Else
MsgBox("Login Failed!!")
[Link] = ""
[Link] = ""
End If
End Sub
End Class

OUTPUT:
Q.5) Write an algorithm, draw a flowchart and develop a [Link] 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
[Link]("Enter 3
Matrix A") 4
For i = 0 To 2 5
6
For j = 0 To 2
7
a(i, j) =
8
[Link]()
9
Next j
Next i
Enter Matrix B
[Link]("Enter
11
Matrix B")
22
For i = 0 To 2 33
For j = 0 To 2 44
b(i, j) = 55
[Link]() 66
Next j 77
Next i 88
99
[Link]("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

[Link](c(i, j) & " ")


Next j

[Link](vbCrLf)
Next i
[Link]()
End Sub
End Module
Q.6) Write an algorithm, draw a flowchart and develop a [Link] 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
[Link]
Dim bs, da, hra, ta, pf, nets

bs = Val([Link])

da = (5 / 100) * bs
[Link] = da
hra = (10 / 100) * bs
[Link] = hra
ta = (12 / 100) * bs
[Link] = ta
pf = (6 / 100) * bs
[Link] = 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 [Link] 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
[Link](6.0)
[Link](7.0)
[Link](5.0)
volume = [Link]()
[Link](“Volume of Box1 : {0}”, volume)
[Link]()
End Sub
End Module

OUTPUT:
Volume of Box1 : 210
Q.8) Write an algorithm, draw a flowchart and develop a [Link] 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
[Link]("Marks :
Public Sub {0}", marks)
SetPersonalInfo(ByVal i As
Integer, ByVal n As String) [Link]("Per :
id = i {0}", per)
name = n
End Sub [Link]("Grade :
{0}", grade)
Public Sub End Sub
PrintPersonalInfo() End Class

[Link]("Id : Sub Main()


{0}", id) Dim S As New
StudentResultInfo()
[Link]("Name :
{0}", name) [Link](101, "Yash",
End Sub 452, 90.4, "A")
End Class [Link]()
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 [Link] windows
application to create data bound control for retrieving the data from database.
CODE:
Imports [Link]
Public Class Form1
Dim con As New [Link]
Dim inc, maxrows As Integer
Dim ds As New DataSet
Dim da As [Link]
Dim cb As New [Link](da)
Private Sub Form1_Load(By Val sender As [Link],ByVal e As
[Link])Handels [Link]
[Link]=”Provider=[Link].12.0;”
da=New [Link](“select* from stud”, con)[Link](ds,”stud”)
maxrows=[Link](“stud”).[Link]
inc = 0
[Link]=[Link](“stud”).Rows(inc).Item(0)
[Link]=[Link](“stud”).Rows(inc).Item(1)
[Link]=[Link](“stud”).Rows(inc).Item(2)
[Link]=[Link](“stud”).Rows(inc).Item(3)
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs)Handles [Link]
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 [Link]
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 [Link]
If inc<> 0 Then
Inc = 0
navigateRecords()
End If
End Sub
Private Sub Button4_Click(sender As Object, e As EventArgs)Handles [Link]
If inc<>maxrows – 1Then
Inc = maxrows -1
navigateRecords()
End If
End Sub
Private Sub navigateRecords()
[Link]=[Link](“stud”).Rows(inc).Item(0)
[Link]=[Link](“stud”).Rows(inc).Item(1)
[Link]=[Link](“stud”).Rows(inc).Item(2)
[Link]=[Link](“stud”).Rows(inc).Item(3)
End Sub
End Class
OUTPUT:
Q.10) Write an algorithm, draw a flowchart and develop a [Link] windows
application access data in a DataGridView control using code.
CODE:
Imports [Link]
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs)Handles [Link]
Dim connectionString As String=”Provider=[Link].12.0;”
Dim connection As New OleDbConnection(connectionString)
Dim dataadapter As New OleDbDataAdapter(sql,connection)
Dim ds As New DataSet()
[Link]()
[Link](ds,”stud”)
[Link]()
[Link]=ds
[Link]=”stud”
End Sub
End Class
OUTPUT:

You might also like