Adding Methods in Class in Visual Basic
Methods are the block of code statements which used for executing several common tasks. In order to add methods in visual basic we need to declare or define methods in class and later use it with objects.
Example
Class Example1 Private dummyVariable As Integer Public Function Example1Function(ByVal var As Integer) dummyVariable = var Return dummyVariable End Function End Class Module Module1 Sub Main() Dim obj As New Example1() Dim number1 As Integer number1 = obj.Example1Function(20) Console.WriteLine(number1) Console.ReadLine() End Sub End Module
Output
20