Substitute a default value if an optional parameter is not provided
Function fullName3(strName As String, Optional strMName As String = "java2s", Optional strLName As String)
msgBox strName
msgBox strMName
msgBox strLName
End Function
Sub getName3()
Dim strFirstName As String
Dim strLastName As String
Dim strFullName As String
strFirstName = "First"
strLastName = "Last"
strFullName = fullName3(strFirstName, , strLastName)
msgBox strFullName, , "Full Name"
End Sub
Related examples in the same category