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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • 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.