Link to home
Start Free TrialLog in
Avatar of Peanuthead
Peanuthead

asked on

Need Help with a Loop

I am currently doing a project which lets me be able to tell the time of a place using the longitude and latitude.  I also need to use a type of WHile loop.  How do i assign a vlaue to the numbers in the longitude and latitude in order to figure out the time? THANX
Avatar of twolff
twolff

Need more information.
> Do you want to assign the lat and lon that is kept somewhere to variables?

> Or are you wanting the actual calculation
Not sure what you would need a loop here for.
I would think you would define areas of lat/long and their corresponding offsets to GMT and go from there

Time doesn't change based on latitude.
There is one hour difference for each 15 degrees longitude.
To expand on that, you might have the following as a calculation:

Hour = GMT + (Longitude \ 15)
Avatar of Peanuthead

ASKER

Sorry, my retarded friend typed that in....the project im doing for school requires me to extract the longitude from a text file with a list of about 50 cities in this format:
Washington 24 30 Long 100 45 Lat E
etc....
etc....
somewhat like that
now, i need to have a drop down combobox that the user can select from that allows them to select one of those cities.  i figured that part out..its pretty damned easy. WHAT I NEED TO KNOW:
How do i get the longitude outta that.  And how do i get the "E" or "W" out of it too.(For "E"ast or "W"est of the prime meridian.)  THAT is what used a while loop.  Thats all i need to know.  After i can do that the rest is easy.  thanks and sorry about my stupid friend ;)
ASKER CERTIFIED SOLUTION
Avatar of Johnn
Johnn

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
The answer from Johnn will work, but may I suggest using a collection to hold the information. You could create a class with a property for each line read from the text file.

Also, if your line is always delimited and not fixed length. I would suggest writing a function that you pass the string and the delimiter and it will extract the information and return it to you. This way you can take the code to any application. I have many modules of such funtions, that I carry to every job.


If you want more information(samples), just let me know. Also, what version of VB are you using?