Calculating moon phases

Der Mond

Member
Licensed User
Longtime User
Hi, is there a way to calculate the moon phase with B4A.

Thanks at all
 

Der Mond

Member
Licensed User
Longtime User
Found!

Thanks so much for the help, :sign0098:
I translated the code (from site http://www.voidware.com/moon_phase.htm) in B4A and it is OK.

This is the code:

Sub MoonPhase As String
Dim c,e, b As Int
Dim jd As Double

Year = DateTime.GetYear(DateTime.Now)
Month = DateTime.GetMonth(DateTime.Now)
Day = DateTime.GetDayOfMonth(DateTime.Now)

If (Month < 3) Then
Year = Year - 1
Month = Month + 12
End If
Month = Month + 1

c = 365.25 * Year
e = 30.6 * Month
jd = c + e + Day - 694039.09
jd = jd / 29.53
b = jd
jd = jd - b
b = jd * 8 + 0.5
b = Bit.AND(b, 7)
Select b
Case 0
Return "New"
Case 1
Return "Waxing Crescent"
Case 2
Return "First Quarter"
Case 3
Return "Waxing Gibbous"
Case 4
Return "Full"
Case 5
Return "Waning Gibbous"
Case 6
Return "Last Quarter"
Case 7
Return "Waning Crescent"
End Select
end sub
 
Upvote 0
Top