Executing Actions with Methods
A method is a member that performs an operation. Methods are of two kinds: Sub
(which does not return values) and Function
(which returns a value). The following are minimal examples of methods:
Sub DoSomething() If IO.File.Exists("C:\SomeFile.txt") = False Then Throw New IO.FileNotFoundException Else Console.WriteLine("The file exists") End IfEnd SubFunction DoSomethingElse() As Boolean Dim result As Boolean = IO.File.Exists("C:\SomeFile.txt") Return resultEnd Function
This book makes intensive use of methods, so detailed descriptions on implementations are provided across chapters.
Scope
Methods’ visibility within types can be assigned using one of the ...
Get Visual Basic 2015 Unleashed 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.