Jump to content
The simFlight Network Forums

Question to VB programmers


Recommended Posts

Hi All ,

I am asking this question to VB programmers. Peter descrbide me someting in other forum but couldnt correct the problem

My problem is while getting the Centre tank level and altitude value from fsuipc the value changes from + values to - valuse than to +values again , something like thid crazy thnigs

these are the codes i am using for centtre fuel level and altitujde

Altitude ocde :

Dim fuel10 As Integer

Dim dwResult10 As Long

Call FSUIPC_Read(&H20, 4, VarPtr(fuel10), dwResult10)

Call FSUIPC_Process(dwResult10)

Label19.Caption = fuel10

Fuel centre:

Dim fuel8 As Integer

Dim dwResult8 As Long

Call FSUIPC_Read(&HB7C, 4, VarPtr(fuel8), dwResult8)

Call FSUIPC_Process(dwResult8)

Text36.Text = fuel8

THIS CODES ARE without dividing or multipling with the values with 256 or 65536 or sometging like tihs .. because i got - values and wrong values from 1st steps..

Link to comment
Share on other sites

the value changes from + values to - valuse than to +values again

For values that can only ever be positive, you cannot have negative values unless you are storing them and using them incorrectly. For example, in a BYTE (8-bit) variable, the value 255 is positive and the value -1 is negative, but they are BOTH represented by hex FF (11111111). You need to understand that "positive" and "negative" are not absolute but dependent on the way you declare and/or use the values you have.

Dim fuel10 As Integer

Dim dwResult10 As Long

Call FSUIPC_Read(&H20, 4, VarPtr(fuel10), dwResult10)

Call FSUIPC_Process(dwResult10)

Label19.Caption = fuel10

I have no idea what Label19.Caption is, but why is the dwResult10 declared as "Long" but the "fuel10" as Integer? Is the VB Long unsigned whilst Integer is signed?

And why is the place for "fuel10" provided as "VarPtr(fuel10)" whilst the return value for dwResult10 is just left as it is? Both should be pointers to the variable to receive the result -- how can one be a "VarPtr" parameter, whatever that means, whilst the other not? They should surely be on the same footing? Both are returning 32 bit values, after all. There's little difference at all.

I don't know VB, but from this example I am sorry to sat that it really looks as if you do not know quite enough about it either. I do hope someone who does know a little more about it can intervene here and help you sort this out!

Regards,

Pete

Link to comment
Share on other sites

Thecode you wroteL

Dim fuel10 As Integer

Dim dwResult10 As Long

Call FSUIPC_Read(&H20, 4, VarPtr(fuel10), dwResult10)

Call FSUIPC_Process(dwResult10)

Label19.Caption = fuel10

Fuel centre:

Dim fuel8 As Integer

Dim dwResult8 As Long

Call FSUIPC_Read(&HB7C, 4, VarPtr(fuel8), dwResult8)

Call FSUIPC_Process(dwResult8)

Text36.Text = fuel8

I am not sure why you wanted to use 'dwResult##' . A swResult in VB allows offset values to process through. So here try...

Dim fuel10 As Long

Dim fuel8 As Long

Dim dwResult As Long

Call FSUIPC_Read(&H20, 4, VarPtr(fuel10), dwResult)

Call FSUIPC_Process(dwResult)

Label19.Caption = fuel10

Fuel centre:

Call FSUIPC_Read(&HB7C, 4, VarPtr(fuel8), dwResult)

Call FSUIPC_Process(dwResult)

Text36.Text = fuel8

Any categories given offsets will process with only one dwResults... You could do some modfication in modules or .BAS to have multiple dwResults. But I personally think it wouldnt be necessary, kinda of waste.

Link to comment
Share on other sites

High Octane

The Fuel Level is OK now ..

But altitude is still worng at me ..

beause although i climb thru high levels in fs the altitude goes down , suddenly up , suddenlyt down something crazy ..

but fuel level is ok now thanks ..

Link to comment
Share on other sites

  • 1 year later...

Hello,

I'm having also trouble with getting variables with FSUIPC_read, here is my code.

Dim dwResult As Long
Dim alt As Long


Private Sub cmd_Click()
Call FSUIPC_Read(&H20, 4, VarPtr(alt), dwResult)
Call FSUIPC_Process(dwResult)
Form1.Caption = alt
Call FSUIPC_Close
End Sub

Private Sub Form_Load()
FSUIPC_Initialization
FSUIPC_Open SIM_ANY, dwResult
End Sub

The strange thing is, it says that i'm flying at exactly "33474" ft height, no matter how high i fly. I know i'm doing something wrong, but what ? :(

Link to comment
Share on other sites

Call FSUIPC_Read(&H20, 4, VarPtr(alt), dwResult)

...

The strange thing is, it says that i'm flying at exactly "33474" ft height, no matter how high i fly. I know i'm doing something wrong, but what ? :(

Please, please do read the documentation a little more thoroughly. It isn't that obscure! Offset 0020, which you are reading, clearly says that it is the GROUND altitude, in metres x 256. The ground beneath you is NOT going to be going up with you when you climb, nor down when you descend!!! The ground altitude depends on the mesh underlying your scenery!

33474/256 = 131.73 metres or 432 feet. That's the ground altitude above sea level at the spot beneath the aircraft.

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.