Jump to content
The simFlight Network Forums

reading altitude in VB 6


Recommended Posts

Hi,

This is the first time that I have been playing around with SDK and have quick question. I am trying to read Altitude using the below code but I always get an 'overflow' error.

What type would the altitude variable be considering it is 8bytes long? I have currently defined it as long.

If FSUIPC_Read(&H570, 8, VarPtr(altitude), dwResult) Then

' "Read" proceeded without any problems

If FSUIPC_Process(dwResult) Then

' "Process" proceeded without any problems

lblAltitude.Caption = Int((altitude * 3.28084) / (65536 * 65536))

Else

' Unable to "Process"

lblError.Caption = "Processing: " & ResultText(dwResult)

End If

Else

' Unable to "Read"

lblError = "Reading: " & ResultText(dwResult)

End If

Many thanks

Graham

Link to comment
Share on other sites

What type would the altitude variable be considering it is 8bytes long? I have currently defined it as long.

Unless it's a 64-bit compiler (for a 64-bit processor), a normal "long" won't be long enough. I don't know VB -- someone may chip in and help out -- but if you read the description of what is in 0570 again you will see that it would be possible to read the 8 bytes into two "longs" in an array (or even use two separate reads into two separate longs). The first will contain the fractional metres and the second the whole number of metres. You'd need to treat the fraction as unsigned, though, and I know that is next-to-impossible in VB. In my opinion, from what I have learned here, VB is a very frustrating language I'm afraid.

Pete

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use. Guidelines Privacy Policy We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.