December 2001
Beginner
976 pages
22h 4m
English
You have seen examples of Visual Basic built-in functions when you learned about conversion between different data types. We have used these functions in some of the examples you have seen since then. A function is a subroutine that returns a value. The syntax is slightly different but the functionality is identical. The difference is that it returns a value. Let's modify your last example to transform the Add subroutine into a function.
Module Module1
Sub Main()
Console.Out.WriteLine("Enter a value for i and press <Enter>:")
Dim i As Integer
i = CInt(Console.In.ReadLine())
Console.Out.WriteLine("Enter a value for j and press <Enter>:")
Dim j As Integer
j = CInt(Console.In.ReadLine())
Dim sum As Integer
sum = Add(i, j) WaitForEnter("The ...Read now
Unlock full access