Mega Code Archive

 
Categories / VisualBasic Script / Language Basics
 

Substitute a default value if an optional parameter is not provided

Function fullName3(strName As String, Optional strMName As String = "rntsoft", 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