How to use Class in VB.NET
A class defines a collection of encapsulated instance variables, methods, functions, optionally including implementations of those types and a constructor and destructor.
What is a Class
A class defines a collection of encapsulated instance variables and methods, functions, optionally including implementations of those types and a constructor and destructor.
In this article, we will see how to use Visual Studio to add and work with classes using VB.NET.
For adding a new class to a project, you have to follow this steps:
You can add class by two ways, "directly go to the project menu and select Add New Item or Go the solution explorer Right click on project and chose Add New Item option", in Your Opened Project.
Choose Visual Basic Class From Solution items and Click on Add button.
When you add a class to a project, Visual Basic Automatically generates the Class and End Class Statement so you can enter the code for the class between them.
As for displaying simple string in a console application like ("Welcome User"), you have to write this code between the newly added class body.
Public Class test
And write this code in existing Module body .
Dim obj As New test()
After writing this code, build or debug the application. The output screen looks like following.
In this simple article, you can learned how to add a new class to an existing project using Visual Studio and how to call this class from a project module.