Chapter 10. Methods
A method is a collection of executable statements used to accomplish some task. Methods are the primary way to take action in a program.
Subroutines and Functions
A method is either a function or a subroutine. A subroutine performs some action and returns. For example:
Sub Main() Console.WriteLine("Hello, world!") End Sub
A function, on the other hand, calculates a value that is returned to the caller when the function ends. When a function is declared, it specifies the type of the value that it returns in much the same way that a variable specifies its type. For example, the following function calculates the sum of two numbers and returns the result.
Function Add(ByVal x As Integer, ByVal y As Integer) As Integer Return x + ...
Get Visual Basic .NET Programming Language, The now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.