10-04-2019, 02:50 AM
please help complete the formula below from vba to hp prime :
Public Function JDEMinElongTracking(JDE As Double) As Double
Dim JDEAwal As Double
Dim JDEProsess(3)
Dim ELONG(3)
Dim Intervals(7)
Dim ELONGMIN As Double
Dim Hasil As String
Dim I As Integer
Dim J As Integer
Dim k As Integer
Dim L As Integer
Intervals(0) = 1 / 24
Intervals(1) = 1 / 24 / 60
Intervals(2) = 1 / 24 / 60 / 60
Intervals(3) = 1 / 24 / 60 / 60 / 10
Intervals(4) = 1 / 24 / 60 / 60 / 100
Intervals(5) = 1 / 24 / 60 / 60 / 1000
Intervals(6) = 1 / 24 / 60 / 60 / 10000
Intervals(7) = 1 / 24 / 60 / 60 / 100000
JDEAwal = JDE
While I < 7
DoEvents
For J = 0 To 3
If J = 0 Then
JDEProsess(J) = JDE
Else
JDEProsess(J) = JDE + Intervals(I) * J
End If
ELONG(J) = MoonSunGeocentricElongation(JDEProsess(J))
Next
ELONGMIN = ELONG(0)
For k = 0 To 3
If ELONG(k) < ELONGMIN Then ELONGMIN = ELONG(k)
Next
For L = 0 To 3
If ELONG(L) = ELONGMIN Then
If L = 0 Or L = 3 Then
JDE = JDEProsess(L) + Intervals(I) * (L - 1)
Else
JDEMinElongTracking = JDEProsess(L)
On Error Resume Next
JDE = JDEProsess(L) - Intervals(I + 1)
I = I + 1
End If
End If
Next
Wend
End Function
Public Function JDEMinElongTracking(JDE As Double) As Double
Dim JDEAwal As Double
Dim JDEProsess(3)
Dim ELONG(3)
Dim Intervals(7)
Dim ELONGMIN As Double
Dim Hasil As String
Dim I As Integer
Dim J As Integer
Dim k As Integer
Dim L As Integer
Intervals(0) = 1 / 24
Intervals(1) = 1 / 24 / 60
Intervals(2) = 1 / 24 / 60 / 60
Intervals(3) = 1 / 24 / 60 / 60 / 10
Intervals(4) = 1 / 24 / 60 / 60 / 100
Intervals(5) = 1 / 24 / 60 / 60 / 1000
Intervals(6) = 1 / 24 / 60 / 60 / 10000
Intervals(7) = 1 / 24 / 60 / 60 / 100000
JDEAwal = JDE
While I < 7
DoEvents
For J = 0 To 3
If J = 0 Then
JDEProsess(J) = JDE
Else
JDEProsess(J) = JDE + Intervals(I) * J
End If
ELONG(J) = MoonSunGeocentricElongation(JDEProsess(J))
Next
ELONGMIN = ELONG(0)
For k = 0 To 3
If ELONG(k) < ELONGMIN Then ELONGMIN = ELONG(k)
Next
For L = 0 To 3
If ELONG(L) = ELONGMIN Then
If L = 0 Or L = 3 Then
JDE = JDEProsess(L) + Intervals(I) * (L - 1)
Else
JDEMinElongTracking = JDEProsess(L)
On Error Resume Next
JDE = JDEProsess(L) - Intervals(I + 1)
I = I + 1
End If
End If
Next
Wend
End Function