vb.net assignments Oct 2018
vb.net assignments Oct 2018
Sanstha’s
L.K.Dr.P.R.Ghogrey Science College, Dhule
Department of Computer Science
Sub:- VB.NET
Roll No : Date:
Name :-
Assignment No- 1)Sorting of Array in descending order –console applicaton
Module Module1
Sub Main()
Dim a(10), i, j, temp As Integer
temp = 0
Console.WriteLine("enter Array")
For i = 1 To 10
a(i) = Val(Console.ReadLine())
Next
For i = 1 To 10
For j = 1 To 10
If a(i) > a(j) Then
temp = a(i)
a(i) = a(j)
a(j) = temp
End If
Next
Next
Console.WriteLine("sorted desending order of array")
For i = 1 To 10
Console.WriteLine("{0}", a(i))
Next
Console.ReadKey()
End Sub
End Module
enter Array
100
101
80
105
70
104
85
110
66
77
sorted desending order of array
110
105
104
101
100
85
80
77
70
66
S.S.V.P. Sanstha’s
L.K.Dr.P.R.Ghogrey Science College, Dhule
Department of Computer Science
Sub:- VB.NET
Roll No : Date:
Name :-
Assignment No- 2)Write a Window based application to find the maximum of 3 numbers
End If
Else
If (b > c) Then
MsgBox("b is greater")
Else
MsgBox("c is greater")
End If
End If
End Sub
End Class
S.S.V.P. Sanstha’s
L.K.Dr.P.R.Ghogrey Science College, Dhule
Department of Computer Science
Sub:- VB.NET
Roll No : Date:
Name :-
Assignment No- 3)Write a Window based application to find Factorial of given no.
Module Module1
sub division(byval num1 as integer,byval num2 as integer)
dim result as integer
try
result=num1\num2
catch e as dividebyzeroexception
console.writeline("exception caught:{0}",e)
finally
console.writeline("result:{0}",result)
end try
end sub
Sub Main()
division(25, 0)
console.readkey()
End Sub
End Module
‘output
n4\ConsoleApplication4\exe1.vb:line 5
result:0
S.S.V.P. Sanstha’s
L.K.Dr.P.R.Ghogrey Science College, Dhule
Department of Computer Science
Sub:- VB.NET
Roll No : Date:
Name :- :-
Assignment No- 7)Write a VB.Net Program to demonstrate Single Inheritance(GCD)
Module Module1
Class base
Public a, b As Integer
Public Sub getno()
Console.WriteLine("enter any two no")
a = CInt(Console.ReadLine())
b = CInt(Console.ReadLine())
End Sub
End Class
Class derived
Inherits base
Public Sub calgcd()
While a <> b
If a > b Then
a = a - b
Else
b = b - a
End If
End While
Console.WriteLine("gcd=" & a)
End Sub
End Class
Sub Main()
Dim c As New derived()
c.getno()
c.calgcd()
Console.ReadKey()
End Sub
End Module
‘Output
15
gcd=3
S.S.V.P. Sanstha’s
L.K.Dr.P.R.Ghogrey Science College, Dhule
Department of Computer Science
Sub:- VB.NET
Roll No : Date:
Name :-
Assignment No- 8) VB.Net Program to demonstrate Interface
Module Module1
'create interface
Public Interface i1
Sub print1()
End Interface
Public Interface i2
Sub print2()
End Interface
'create derived class
Public Class class1
Implements i1, i2
Public Sub print1() Implements i1.print1
console.writeline("Interface 1 is calling")
End Sub
Public Sub print2() Implements i2.print2
console.writeline("Interface 2 is calling")
End Sub
Public Sub print3()
console.writeline("class 1 is calling")
End Sub
End Class
Sub Main()
Dim c1 As New class1()
c1.print1()
c1.print2()
c1.print3()
Console.ReadKey()
End Sub
End Module
‘Output
Interface 1 is calling
Interface 2 is calling
class 1 is calling
S.S.V.P. Sanstha’s
L.K.Dr.P.R.Ghogrey Science College, Dhule
Department of Computer Science
Sub:- VB.NET
Roll No : Date:
Name :-
Assignment No- 9) VB.Net Program to demonstrate Polymorphism
Module Module1
Class employ
Console.WriteLine("I am an employee")
End Sub
End Class
Class manager
Inherits employ
Console.WriteLine("I am a manager")
End Sub
End Class
Sub Main()
e1.work()
e1 = New manager()
e1.work()
Console.ReadKey()
End Sub
End Module
'output
I am an employee
I am a manager
S.S.V.P. Sanstha’s
L.K.Dr.P.R.Ghogrey Science College, Dhule
Department of Computer Science
Sub:- VB.NET
Module Module1
Public Class sample
Private a As Integer
Public Sub New(ByVal setval As Integer)
a = setval
End Sub
Public Function display()
Return a
End Function
End Class
Sub Main()
Dim test As New sample(5)
Console.WriteLine("Value of a is initialized to:")
Console.WriteLine(test.display())
Console.ReadLine()
End Sub
End Module
Output :-