Reputation: 396
The following custom function takes one optional integer as argument. If the argument is missing, should return 1. If the argument was passed, should return the argument value.
The problem: if the argument is missing, the function returns 0 instead of 1.
any thoughts?
Function f(Optional i As Integer) As Integer
If IsMissing(i) Then
f = 1
Else
f = i
End If
End Function
Upvotes: 1
Views: 954
Reputation: 33476
Function f(Optional i As Integer = 1) As Integer
f = i
End Function
Upvotes: 4