VBA/Excel/Access/Word/Language Basics/Optional Arguments
Версия от 16:33, 26 мая 2010; (обсуждение)
Using Optional Arguments
Function Avg(num1, num2, Optional num3)
Dim totalNums As Integer
totalNums = 3
If IsMissing(num3) Then
num3 = 0
totalNums = totalNums - 1
End If
Avg = (num1 + num2 + num3) / totalNums
End Function
Sub avgSub()
MsgBox Avg(2, 3)
MsgBox Avg(2, 3, 5)
End Sub