Created
August 28, 2020 08:27
-
-
Save dj1711572002/0b9357d5693f6aca09dd5c47ca46bb77 to your computer and use it in GitHub Desktop.
VBNET_StatisticModule00_MovingAverageFunction
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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