As you have seen, a subroutine is a language construct that allows you to split a large task into smaller pieces. In the previous example, you implemented a subroutine that does the same thing every time it is called: outputs the same string to the console, and then waits until the user presses Enter. This case is rarely useful. There are many cases when you would like the subroutine to do the same operation, but on different data. In this example, we would like to output a different string when the user has entered an incorrect value and the program will terminate abnormally, and a success message when the task of summing the array elements is successful. This is achievable through the use of subroutines with arguments, as illustrated ...

Get Visual Basic® .NET by Example now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.