LoginSignup
4
4

More than 5 years have passed since last update.

ParamArrayを用いたサンプルプログラム

Posted at

ParamArrayの使い方を知らなかったのでサンプル.

Option Explicit
' 平均を求めるAverageメソッド
Public Function Average(ParamArray Data()) As Double
  Dim i As Variant

  For Each i In Data
    Average = Average + i
  Next i

  Average = Average / (UBound(Data) + 1)
End Function

Private Sub Test()
  Debug.Print Average(1, 2, 3, 4, 5)
End Sub

Test() を実行後のイミディエイトウィンドウ

3
4
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
4