High-Octane Posted February 28, 2004 Report Share Posted February 28, 2004 Guys, I'm working wn Altitude using VB6 And I have encountered some problem on calcluation Or did I write string incorrect?? Let take a look at yje string I wrote: Acknowledge: Altitude, Offset Value H570, 8 data bit String I wrote: Dim Fake64bit As currency Dim Altitude As Double Dim dwResult As Long If FSUIPC_Read(&H570, 8, VarPtr (Fake64bit), dwResult) Then Alritude = Fake65bit * 10000# Altitude = Altitude *360#/ (65536# * 65536#) Altlbl.caption = (Fake64) End If Running FS2002/My form Creation I get: FS2002:Alt 306 My form: 8729354 something Obviously, I did wrong on calucation... can anyone tell me me what did I do wrong?? Thanks in advance Link to comment Share on other sites More sharing options...
rickalty Posted February 28, 2004 Report Share Posted February 28, 2004 You could always just do what I did - get the altitude from offset 3324 instead. Then you jut DIM it as Long and use it directly. Richard Link to comment Share on other sites More sharing options...
rickalty Posted February 28, 2004 Report Share Posted February 28, 2004 Or alternatively, read a Long at 574 for the whole meters, and a Long at 570 Also, I don't see why you're doing the calculations at all - it looks to me like the whole meters are stored directly at 574, and the fractions directly at 570 - no 65536*65536 calcs needed. Richard Link to comment Share on other sites More sharing options...
Pete Dowson Posted March 12, 2004 Report Share Posted March 12, 2004 Sorry for the delay in replying -- I've been on holiday with no Internet access. I'm just trying to catch up with an enormous backlog now! Altitude, Offset Value H570, 8 data bit String I wrote: Dim Fake64bit As currency Dim Altitude As Double Dim dwResult As Long If FSUIPC_Read(&H570, 8, VarPtr (Fake64bit), dwResult) Then Alritude = Fake65bit * 10000# Altitude = Altitude *360#/ (65536# * 65536#) Altlbl.caption = (Fake64) End If The altitude there is NOT floating poiint, but fixed point. The integer in metres is 32-bits (4 bytes) at 0574, the fraction is in 0570. Best to read it into an array of two integers. Read metres in the 2nd and the fraction (UNsigned) in 1/(65536*65536) ths in the first. Regards, Pete Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now