You are on page 1of 14

DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING

ARAVALI COLLEGE OF
ENGINEERING & MANAGEMENT
(Jasana Tigaon Road Greater Faridabad Haryana 121001)

VB.NET LAB
LAB FILE
(2020 - 2023)
FOR

5TH Semester

Submitted To. Submitted By

Ms. Pratima Sharma. Aman Daswal

20BCA05
`

Sr No. Programs Date Signature

1. Program to Print Hello World

2. Write a Program on Arithmetic Operation

3. Write a Program on String concatenation

4. Write a Program to Find Area of Rectangle

5. Sum of Two Number Using by Function

6. Write a Program on Constructor

7. Write a Program on Class

8. Write a Program to Inheritance program

9. Write a Program on an Array

10. Write a Program on Destructor


Program 1
1.Program to Print Hello World
Syntax :-
Imports System

Module Module1

Sub Main()

Console.WriteLine("Hello World!")

End Sub

End Module

Output :-
Program 2
2.Write a Program on Arithmetic Operation
Syntax :-
Imports System

Public Class Test

Public Shared Sub Main()

Dim x, y as Integer

x = 10

y = 25

System.Console.WriteLine("Sum of x and y = " & (x+y))

System.Console.WriteLine("Substraction of x and y = " & (x-y))

System.Console.WriteLine("Multiplication of x and y = " & (x*y))

System.Console.WriteLine("Division of x and y = " & (x/y))

End Sub

End Class

Output :-
Program 3
3. Write a Program on String concatenation
Syntax :-
Module strings

Sub Main()

Dim fname, lname, fullname, greetings As String

fname = "Umesh"

lname = "Kumar"

fullname = fname + " " + lname

Console.WriteLine("Full Name: {0}", fullname)

End Sub

End Module

Output :-
Program 4
4. Write a Program to Find Area of Rectangle
Syntax :-
Imports System

Module Module1

Class Figure

Public length As Double

Public breadth As Double

End Class

Sub Main()

Dim Rectangle As Figure = New Figure()

Dim area As Integer

Rectangle.length = 8

Rectangle.breadth = 7

area = Rectangle.length * Rectangle.breadth

Console.WriteLine("Area of Rectangle is : {0}", area

End Sub

End Module

Output :-
Program 5
5. Write a Program to Sum of Two Number Using by Function
Syntax :-

Module Module1

Function AddNum( num1 As Integer, num2 As Integer) As Integer

Dim num3 As Integer = 0

num3 = num1 + num2

AddNum = num3

End Function

Sub Main()

Dim num1 As Integer = 0

Dim num2 As Integer = 0

Dim num3 As Integer = 0

num1=34

num2=65

Console.WriteLine("Enter number1: ",num1)

Console.WriteLine("Enter number2: ",num2)

num3 = AddNum(num1, num2)

Console.WriteLine("Addition is: {0}", num3)

End Sub
End Module

Output :-
Program 6
6. Write a Program on Constructor
Syntax :-
Imports System

Module Default_Const

Class Student

Public Name As String

Public Age As Integer

Public Sub New()

name = "Aman Daswal"

Age = 22

End Sub

End Class

Sub Main()

Dim Student As Student = New Student()

Console.WriteLine(" Student Name is : {0}", Student.Name)

Console.WriteLine(" Student Age is : {0}", Student.Age)

End Sub

End Module

Output :-
Program 7
7. Write a Program on Class
Syntax :-
Module Module1

Class Student

Public name As String

Public age As Integer

Public RollNo As String

End Class

Sub Main()

Dim obj As Student = New Student()

obj.name = "Umesh"

obj.age = 22

obj.RollNo = "20BCA52"

Console.WriteLine(obj.name)

Console.WriteLine(obj.age)

Console.WriteLine(obj.RollNo)

Console.Read()

End Sub

End Module

Output :-
Program 8
8. Write a Program to Inheritance program
Syntax :-
Module Module1

Class PersonalInfo

Dim id As Integer

Dim name As String

Public Sub SetPersonalInfo(ByVal i As Integer, ByVal n As String)

id = i

name = n

End Sub

Public Sub PrintPersonalInfo()

Console.WriteLine("Id : {0}", id)

Console.WriteLine("Name : {0}", name)

End Sub

End Class

Class StudentResultInfo

Inherits PersonalInfo

Dim marks As Integer

Dim per As Double

Dim grade As String

Public Sub SetInfo(ByVal i As Integer, ByVal n As String, ByVal m As Integer, ByVal p As Double, ByVal
g As String)

SetPersonalInfo(i, n)

marks = m

per = p

grade = g
End Sub

Public Sub PrintInfo()

PrintPersonalInfo()

Console.WriteLine("Marks : {0}", marks)

Console.WriteLine("Per : {0}", per)

Console.WriteLine("Grade : {0}", grade)

End Sub

End Class

Sub Main()

Dim S As New StudentResultInfo()

S.SetInfo(10, "Umesh", 420, 50.6, "B")

S.PrintInfo()

End Sub

End Module

Output :-
Program 9
9. Write a Program on Constuct an Array
Syntax :-
Imports System

Module num_Array

Sub Main()

Dim i As Integer, Sum As Integer = 0

Dim marks() As Integer = {10, 20, 30, 40, 50, 60}

Console.WriteLine(" Marks in 6 Subjects")

For i = 0 To marks.Length - 1

Console.WriteLine(" Marks {0}", marks(i))

Sum = Sum + marks(i) Next

Console.WriteLine(" Grand total is {0}", Sum)

End Sub

End Module

Output :-

Progr
am 10
10. Write a Program on Destructor
Syntax :-
Module Module1

Class Sample

Public Sub New()

Console.WriteLine("Constructor called")

End Sub

Protected Overrides Sub Finalize()

Console.WriteLine("Destructor called")

End Sub

Public Sub SayHello()

Console.WriteLine("Hello World")

End Sub

End Class

Sub Main()

Dim obj As New Sample()

obj.SayHello()

End Sub

End Module

Output :-

You might also like