Click here to Skip to main content
15,900,725 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I'm trying to make a program that calculates the sunrise, sunset and solar noon based on longitude, latitude and time zone for any city in the world.

How can I do that in vb.net?

Thanks.
Posted
Updated 4-Jun-15 6:33am
v2

1 solution

The calculations for sunrise and sunset are easy to find:
https://en.wikipedia.org/wiki/Sunrise_equation[^]
http://users.electromagnetic.net/bu/astro/sunrise-set.php[^]
http://aa.quae.nl/en/reken/zonpositie.html[^]

You just need to translate the calculation into code.

There's no need to "calculate" noon - it's always at exactly 12 PM. :)
(Unless you mean "solar noon", which is included in the sunrise / sunset calculation.)

EDIT: I've posted the C# code I use to GitHub, which might give you a place to start:
https://gist.github.com/RichardD2/f6b08a5791b21ac77ce7[^]
 
Share this answer
 
v2
Comments
al3abby 4-Jun-15 12:36pm    
If I knew how to translate the calculation into code, I wouldn't have asked!
Richard Deeming 4-Jun-15 12:40pm    
So you're expecting someone else to do your work for you?
al3abby 4-Jun-15 13:04pm    
No, i'm expecting some guidance.
Richard Deeming 4-Jun-15 13:08pm    
The guidance is:
1. Read the details of the calculation, which gives you step-by-step instructions on how to calculate the sunrise, sunset and solar noon times by hand;
2. Convert each manual step to equivalent code;
3. There is no step 3.

If you get stuck with converting a particular step to code, then feel free to ask for help.
al3abby 4-Jun-15 13:31pm    
thank you, you made it clear this time! But the thing is I was looking for someone to guide me on how to convert these equations (which I already know) to a code that vb.net can understand (as I'm still a beginner), so the things that might look obvious to you might seem a little bit difficult to some others. Anyway I'm taking my question somewhere else.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900