Friday, November 19, 2010

What type of Variable should be initialized for comparing Degree:Min:Sec - In VB?

I need to compare astrological data in degree:min:sec what type of variable should i define in VB6?



For example - If degree %26gt;=030:00:00 and degree%26lt;=:059:59:59



how can i code this in VB6? Thank you in advance for the answers.What type of Variable should be initialized for comparing Degree:Min:Sec - In VB?
There are a couple of ways to do this.

First, you could store all that information as a long int as,

bits 1 - 6 : seconds

bits 7 - 12: minutes

bits 13 - 32 : degrees (more bits than you need, but it's what is there)

This way, the comparisons would be exactly as you have written, but accessing and setting the particular pieces of the data would be more difficult (require bitwise operations)



The more likely way to accomplish this would be to define a coordinate object that stores three ints (or shorts), representing seconds, minutes and degrees, and a compareTo that compares first degrees, then (if they are equal) minutes, then seconds.

No comments:

Post a Comment