Solved

# Sun and Moon Position in Lat/Lon from Date/time VB6 - Continue

Posted on 2009-05-06
1,282 Views
This is a continue from http://www.experts-exchange.com/Programming/Languages/Visual_Basic/Q_24363977.html

Because of complex in question and length. I move it to new question so it can be readable and hopefully useful for others.

Question was:
"
I am looking for code in visual basic 6 to get sun and moon position in latitude and longitude.
I have converted the code from this link: http://www.experts-exchange.com/Programming/Languages/CPP/Q_23501542.html?sfQueryTermInfo=1+10+posit+sun
but it is not very acurate.

Does any one have  source code for both sun and moon position in visual basic 6
"
0
Question by:iscode
• 8
• 6
• 2
• +1

LVL 46

Expert Comment

ID: 24323107
Have a look here for VBA code (which is the same as VB6)

Good Luck,

Gary
0

LVL 46

Expert Comment

ID: 24323108
0

LVL 6

Author Comment

ID: 24323938
0

LVL 46

Expert Comment

ID: 24323956
Don't they give you what you want?
0

LVL 6

Author Comment

ID: 24324219
They give me RA= Right ascension and DEC=Declination=Latitude and distance
I need the GHA to get the longitude as we discovered in my first question
http://www.experts-exchange.com/Programming/Languages/Visual_Basic/Q_24363977.html
We had solved that for the sun but not for the moon
0

LVL 46

Expert Comment

ID: 24324262
Does this get you any closer?
http://www.stargazing.net/kepler/sunrise.html
0

LVL 6

Author Comment

ID: 24324357
I have all those too :-) and sunrise and set is not helping me with the moon location as I said sun was solved already in last question but I dont blame you for not reading all that its pretty long,
what I am after now is just moon location latitude and longitude above earth
0

LVL 6

Accepted Solution

iscode earned 0 total points
ID: 24325462
OK I think I found my answer
as I already have RA in moon position I should get gha from this link
http://www.jgiesen.de/elevazmoon/basics/index.htm
Just need to check it out
0

LVL 6

Author Comment

ID: 24326484
Yes actully it works same for the moon as for the sun after I have RA
T = (JD - 2451545.0 ) / 36525;
theta0 = 280.46061837 + 360.98564736629*(JD-2451545.0) + 0.000387933*T*T - T*T*T/38710000.0; // degrees

Local sidereal time:

theta = theta0 + longitude (eastern longitudes positive, western negative)

Hour angle: tau = theta - RA

0

LVL 46

Expert Comment

ID: 24326517
Great!
0

LVL 6

Author Comment

ID: 24327017
Now how do I close the question without delete it?
0

LVL 46

Expert Comment

ID: 24327561
Press the Request Attention
0

LVL 18

Expert Comment

ID: 24328240
That was fast!  Congratulations!
0

LVL 6

Author Comment

ID: 24328742
Thank you mdougan

Well I would never have made it with out your help in first place,
that will be next question, are you inn?
0

LVL 18

Expert Comment

ID: 24328861
Sure, I'm in!  ;-)

All I've thought about the shadow, so far, is that the shadow will fall exactly along a meridian (longitude line), when the earth is perpendicular to the sun (which happens on the equinoxes).  So, on the equinoxes, you would, perhaps, plot a point at every degree of latitude, along the same longitude line, and draw the line between them.

But, as the earth tilts during the course of the year, the line will be more oblique.  In the summer months, for example, the shadow won't extend all the way to the North Pole... they have several months of daylight 24 hours a day.  So, you will need to find some websites that detail the formulas for calculating this shadow, and I suppose that will be different for the different kinds of projections... so, if you are using a Mercator projection, then look specifically for formulas related to that.  If you find a good resource, then I can help you convert it to VB!
0

LVL 6

Author Comment

ID: 24329685
Good
Sound interesting enough and great tips already!
I will see what I can find useful, it can take me few days to prepare this.
0

Expert Comment

ID: 26181719
i dont know if you found the code for the shadows but heres the math for it on your same site

http://www.jgiesen.de/map/index.html

0

## Featured Post

### Suggested Solutions

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone â€¦
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). Uâ€¦
This tutorial demonstrates how to identify and create boundary or building outlines in Google Maps. In this example, I outline the boundaries of an enclosed skatepark within a community park.  Login to your Google Account, then  Google for "Google Mâ€¦

#### Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!