Jump to content
The simFlight Network Forums

Recommended Posts

Posted

Hi.

Sorry about this, can see its been posted before, but I can't find the answer so..

Trying to get the altitude reading from VB6.0, other things are working fine, but the alt reading is totality wrong.

I have tried currency, and double variables, same problem

has anyone a solution on this problem..

best

tore eilertsen

Posted

Hi

Here is the code.

Dim dwResult As Long
Dim fs_speed As Long
Dim fs_gear As Long
Dim fs_alt As Double
Dim alt_tmp As Double

Dim speed_int As Long
Dim booResult As Boolean

'read gear
   booResult = FSUIPC_Read(&HBE8, 4, VarPtr(fs_gear), dwResult)

'Read Speed
   booResult = FSUIPC_Read(&H2B8, 4, VarPtr(fs_speed), dwResult)

 'Read Altitude

   booResult = FSUIPC_Read(&HB4C, 4, VarPtr(fs_alt), dwResult)
   booResult = FSUIPC_Process(dwResult)

 'Action section
   Label5.Caption = fs_gear   'printer ut Gear statur
   Label4.Caption = fs_speed \ 128
   alt_tmp = fs_alt * 3.2  'gir resultat i feet
   Label6.Caption = alt_tmp
End Sub

Posted

Hi,

Offset 0B4C is only 2 bytes long according to the documentation. So you need to use a variable type of Integer in VB6 and set the length of the FSUIPC_Read to 2 not 4. So your code would look like this:

Dim dwResult As Long
Dim fs_speed As Long
Dim fs_gear As Long
Dim fs_alt As Integer
Dim alt_tmp As Double

Dim speed_int As Long
Dim booResult As Boolean

'read gear
   booResult = FSUIPC_Read(&HBE8, 4, VarPtr(fs_gear), dwResult)

'Read Speed
   booResult = FSUIPC_Read(&H2B8, 4, VarPtr(fs_speed), dwResult)

 'Read Altitude

   booResult = FSUIPC_Read(&HB4C, 2, VarPtr(fs_alt), dwResult)
   booResult = FSUIPC_Process(dwResult)

 'Action section
   Label5.Caption = fs_gear   'printer ut Gear statur
   Label4.Caption = fs_speed \ 128
   alt_tmp = fs_alt * 3.2  'gir resultat i feet
   Label6.Caption = alt_tmp
End Sub

I can't test this because I don't have VB6 but I'm pretty sure that will work now.

Paul

Posted

It's just occurred to me that you're probably using the wrong offset. 0B4C looks to be the altitude of the ground not the altitude of your plane.

You probably need 0570 instead:

Dim altitude as Double
Dim FakeAlt As Currency
Dim dwResult As Long
Call FSUIPC_Read(&H570 , 8, VarPtr(FakeAlt), dwResult)
Call FSUIPC_Process(dwResult)
altitude = FakeLat * 10000#
altitude = altitude *  3.28084 / (65536# * 65536#)

Paul

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.