VB 11 Tutorial 5: Getting Started
If you have not yet learnt about Arrays Please refer to Tutorial 4: Here
Today we will be working on how to make a function.
First of all how can we write a Function
Code:
' Example in using functions
Module SubNew
Sub Main()
Console.WriteLine(Me.GetMyName) ' here we are getting a name from a function, a function is used as a variable, As String, can be anything, Example As Integer.
' To use a Function to return a Array, Type this.
Dim MyFriends() As String = GetMyNames()
End Sub
Pirvate Function GetMyName() As String
Return "Samuel"
End Function
Pirvate Function GetMyNames() As String()
Return New String() {"Samuel", "Tim", "Bob", "Tom"}
End Function
End Sub
Today we will be working on how to make a function.
First of all how can we write a Function
Code:
' Example in using functions
Module SubNew
Sub Main()
Console.WriteLine(Me.GetMyName) ' here we are getting a name from a function, a function is used as a variable, As String, can be anything, Example As Integer.
' To use a Function to return a Array, Type this.
Dim MyFriends() As String = GetMyNames()
End Sub
Pirvate Function GetMyName() As String
Return "Samuel"
End Function
Pirvate Function GetMyNames() As String()
Return New String() {"Samuel", "Tim", "Bob", "Tom"}
End Function
End Sub
No comments:
Post a Comment