![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
I've dabbled in "Optional" over the last few days and think I'm coming down against using it. Seems to me like it makes the code harder to read and more complicated. Instead of using Optional, I'm making the parm a Variant and passing Null when it's not used.... then checking for "If Len(theParmValue & "") > 0... to see if it is present. That way I can eliminate checks for IsMissing(theParmValue)... Anybody else have thoughts on this? -- PeteCresswell |
#3
| |||
| |||
|
|
Use the Optional keyword with a = "setting" if there isn't a input. For example: Public Function GetASetting( _ SettingToGet As String, _ Optional TableName As String = "USYS_tblSettings", _ Optional whatDB As DAO.Database = Nothing) _ As Variant If whatever calls this function doesn't supply a TableName, "USYS_tblSettings" is used by default. Saves all that nasty checking for IsMissing... You do still have to check for invalid stuff passed to your function or sub however! |
#4
| |||
| |||
|
|
I've dabbled in "Optional" over the last few days and think I'm coming down against using it. Seems to me like it makes the code harder to read and more complicated. Instead of using Optional, I'm making the parm a Variant and passing Null when it's not used.... then checking for "If Len(theParmValue & "") > 0... to see if it is present. That way I can eliminate checks for IsMissing(theParmValue)... Anybody else have thoughts on this? -- PeteCresswell |
#5
| |||
| |||
|
|
I've dabbled in "Optional" over the last few days and think I'm coming down against using it. Seems to me like it makes the code harder to read and more complicated. Instead of using Optional, I'm making the parm a Variant and passing Null when it's not used.... then checking for "If Len(theParmValue & "") > 0... to see if it is present. That way I can eliminate checks for IsMissing(theParmValue)... Anybody else have thoughts on this? -- PeteCresswell |
#6
| |||
| |||
|
|
I've dabbled in "Optional" over the last few days and think I'm coming down against using it. Seems to me like it makes the code harder to read and more complicated. Instead of using Optional, I'm making the parm a Variant and passing Null when it's not used.... then checking for "If Len(theParmValue & "") > 0... to see if it is present. That way I can eliminate checks for IsMissing(theParmValue)... Anybody else have thoughts on this? |
![]() |
| Thread Tools | |
| Display Modes | |
| |