Procedures in Visual Basic

Just as the subs that handle events receive arguments such as sender (the object that the sub handles) and e (information about the event) general procedures that we write can also receive arguments.

In this example, the Form Load event calls a sub called info and passes the string "Welcome". The sub info receives the arguments nad stores the string "Welcome" as title. It then displays the value title as the text for the form.

'Programmer: Janet Joy
'Illustrate passing a value to a procedure
Public Class Form1
    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        info("Welcome")
    End Sub
    Private Sub info(ByVal title As String)
        Me.Text = title
    End Sub
End Class

When you run this program you will see the word "Welcome"

NEXT: Passing Arguments to a function