forked from dotnet/docs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoptional_1.vb
More file actions
23 lines (18 loc) · 832 Bytes
/
Copy pathoptional_1.vb
File metadata and controls
23 lines (18 loc) · 832 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
Private Sub TestParameters()
' Call the procedure with its arguments passed by position,
studentInfo("Mary", 19, #9/21/1981#)
' Omit one optional argument by holding its place with a comma.
studentInfo("Mary", , #9/21/1981#)
' Call the procedure with its arguments passed by name.
studentInfo(age:=19, birth:=#9/21/1981#, name:="Mary")
' Supply an argument by position and an argument by name.
studentInfo("Mary", birth:=#9/21/1981#)
End Sub
Private Sub studentInfo(ByVal name As String,
Optional ByVal age As Short = 0,
Optional ByVal birth As Date = #1/1/2000#)
Console.WriteLine("name: " & name)
Console.WriteLine("age: " & age)
Console.WriteLine("birth date: " & birth)
Console.WriteLine()
End Sub