0% found this document useful (0 votes)
20 views2 pages

Practical No. 2

The document describes a VB.NET program that demonstrates using a user-defined namespace and existing namespaces. It defines a CustomClass within the MyNamespace namespace, creates an instance of it to display a message. It also uses the DateTime and Random classes from the System namespace to output the current date/time and a random number. The program ends with an exercise to create a student namespace with an info class to output a name.

Uploaded by

Soham KAWARE
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)
20 views2 pages

Practical No. 2

The document describes a VB.NET program that demonstrates using a user-defined namespace and existing namespaces. It defines a CustomClass within the MyNamespace namespace, creates an instance of it to display a message. It also uses the DateTime and Random classes from the System namespace to output the current date/time and a random number. The program ends with an exercise to create a student namespace with an info class to output a name.

Uploaded by

Soham KAWARE
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
You are on page 1/ 2

Practical No.

2
WRITE A PROGRAM USING USER DEFINED AND EXISTING NAMESPACE IN VB.NET
Imports System

Namespace MyNamespace

Public Class CustomClass


Public Sub DisplayMessage()
Console.WriteLine("Hello from MyNamespace!")
Console.ReadLine()
End Sub
End Class
End Namespace

Module Module1
Sub Main()
Dim myObject As New MyNamespace.CustomClass()
myObject.DisplayMessage()

Dim currentDate As DateTime = DateTime.Now


Console.WriteLine("Current Date and Time: " & currentDate.ToString())
Console.ReadLine()

Dim randomValue As New Random()


Dim randomNumber As Integer = randomValue.Next(1, 100)
Console.WriteLine("Random Number: " & randomNumber)
Console.ReadLine()
End Sub
End Module

Output :-
EXERCISE
Q1 WRITE A PROGRAM TO IMPLEMENT THE NAMESPACE STUDENT (TEACHER) IN YOUR VB.NET APPLICATION

Module Module2
Sub Main()

Dim fact As New student.info


fact.name()
Console.ReadKey()

End Sub

End Module

Namespace teacher
Class info
Sub Name()

Console.WriteLine("Diploma second year Computer Engineering")


End Sub
End Class
End Namespace

Output :-

You might also like