Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@dj1711572002
Created August 28, 2020 08:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dj1711572002/0b9357d5693f6aca09dd5c47ca46bb77 to your computer and use it in GitHub Desktop.
Save dj1711572002/0b9357d5693f6aca09dd5c47ca46bb77 to your computer and use it in GitHub Desktop.
VBNET_StatisticModule00_MovingAverageFunction
Module Stat00
Function MovAve(ByRef dA(,) As Long, ByVal colN As Integer, ByVal MA As Integer, ByVal rowN As Integer) As Double()
Dim i, j As Integer
Dim dataSum() As Long
Dim dSum As Long
Dim dataA() As Double '= {0, 0, 0, 0, 0, 0, 0}
'Debug.Print("====colN=" & CStr(colN) & "MA=" & CStr(MA) & "rowN=" & CStr(rowN))
ReDim dataSum(colN + 1)
ReDim dataA(colN + 1)
For j = 0 To colN - 1
dSum = 0
For i = rowN - MA To rowN
dSum = dSum + dA(i, j)
'Debug.Print("dA(" & CStr(i) & "," & CStr(j) & ")=" & CStr(dA(i, j)) & CStr(dataSum(j)))
Next
dataA(j) = CDbl(dSum / MA)
Next
MovAve = dataA
End Function
End Module
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment