Solved

Need Help with a Loop

Posted on 1999-01-14
8
142 Views
Last Modified: 2010-05-03
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
0
Comment
Question by:Peanuthead
8 Comments
 
LVL 1

Expert Comment

by:twolff
ID: 1456278
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
0
 
LVL 3

Expert Comment

by:traygreen
ID: 1456279
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

0
 
LVL 6

Expert Comment

by:clifABB
ID: 1456280
Time doesn't change based on latitude.
There is one hour difference for each 15 degrees longitude.
0
 
LVL 6

Expert Comment

by:clifABB
ID: 1456281
To expand on that, you might have the following as a calculation:

Hour = GMT + (Longitude \ 15)
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

Author Comment

by:Peanuthead
ID: 1456282
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 ;)
0
 
LVL 1

Accepted Solution

by:
Johnn earned 50 total points
ID: 1456283
I'm not really good at reading text files but I assume you can read them one line at a time so do something like this
dim thisline as string
dim eastwest$
dim cityend%
dim cityname$
dim longitude$
dim cboIndex() as string's/b declared in general declarations
While not EOF
    thisline=however you read a line
    eastwest=right$(thisline,1)'get the last character
    cityend%=instr(1,thisline," ")-1
    cityname=left$(thisline,cityend)
    longitude=mid$(thisline,cityend+2,instr(cityend+2,thisline,"L")-1
    combo.additem cityname
    redim preserve cboIndex(0 to combo.listcount-1)
    cboindex(ubound(cboindex))=longitude
wend
'in click event of cboindex retrieve longitute like this
longitute=cboindex(combo.listindex)
0
 
LVL 1

Expert Comment

by:twolff
ID: 1456284
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.


0
 
LVL 1

Expert Comment

by:twolff
ID: 1456285
If you want more information(samples), just let me know. Also, what version of VB are you using?
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
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…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now