Functions can receive arguments just like procedures.
Start a new application and name it Greeting. We are going to write the "Hello World" program in English and Spanish using a function. Write the code as shown below:
'Programmer: Janet JoyNotice that the function header (the first line) has a variable listed in the parameter list. A local variable is used to store the return value. The last statement in the body of the function returns the value.
'Hello World in English or Spanish
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Me.Text = greeting("Spanish")
Public Function greeting(ByVal lang As String) As String
Dim hello As String = "Hello World"
If lang = "Spanish" Then hello = "Hola Mundo"