Objects in VB.NET
What are Objects in VB.NET?
Explanation
Objects
Objects in VB.net are instances of a class. Advantage of objects is that it can be used flexibly by referring the class name without the need to write code.
Every object that has its own Properties, Methods and Events. Properties of the object define the
characteristics, the Methods define the procedure that can operate on a Object. The events are possible actions
that can occur to an object
Example:
Module Module1
Sub Main()
Dim obj As New Subtr
obj.min()
End Sub
Public Class Subtr
Dim a As Integer = 100
Dim b As Integer = 10
Sub min()
Console.WriteLine("Subtraction of 100-10::" & a - b)
Console.ReadLine()
End Sub
End Class
End Module
Result:
Subtraction of 100-10::90
Description:
In the above example,
obj is an instance of the class
Subtr.Using this object the function
min is used without writing any code.