Jump to content
The simFlight Network Forums

VB


Recommended Posts

You could start with downloading my .NET DLL that lets you talk to FSUIPC from any .NET language.

http://forums.simflight.com/viewtopic.php?f=54&t=53255

It has full documentation and an example project in VB.NET that shows how to use the DLL to read and write to/from offsets in FSUIPC.

It doesn't have any examples that deal with fuel, but you can find out which offsets relate to fuel in the "FSUIPC Guide For Programmers" in Pete's FSUIPC SDK.

Paul

Link to comment
Share on other sites

Here is what I have now and it doesn't work... Could someone help me out a bit and change something around, so it works (And yes, the timer is enabled, the interval is 1)(nothing is underlined blue, so the code is correct, but it doesn't change the fuel (and the fuel tank is set to 1, which is all tanks))?

Imports FSUIPC
Public Class Form1
    Private Const AppTitle As String = "FSUIPCClientExample_VB"
    Dim Fuel As Offset(Of Integer) = New FSUIPC.Offset(Of Integer)(&HAF4)
    Dim Tank As Offset(Of Integer) = New FSUIPC.Offset(Of Integer)(&HAF8)
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Tank.Value = 1
    End Sub
    Private Sub button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button2.Click
        Try
            FSUIPCConnection.Open()
            MsgBox("Connected :)")
        Catch ex As Exception
            MessageBox.Show(ex.Message, AppTitle, MessageBoxButtons.OK, MessageBoxIcon.Error)
        End Try
    End Sub
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Fuel.Value = TrackBar1.Value / 256
    End Sub
    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        TextBox1.Text = TrackBar1.Value / 256
    End Sub
End Class

Link to comment
Share on other sites

Hi,

Firstly the offsets you are looking at are documented as being 2 bytes long, not 4 so you should be declaring the offsets as Short not Integer.

The main problem though is that your code never makes a FSUIPCConnection.Process() call. This is the bit that actually gets data from FS and writes it.

You must call process() to update the values of all of your offsets you have declared. If you have changed the value of any offset, Process() will also send that value to FS.

On your button click, you need to add a Process call after you set Fuel.Value.

If you want your text box to show you the current fuel then it should be something more like this....

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        FSUIPCConnection.Process()
        TextBox1.Text = Fuel.Value / 256
End Sub

Have you read the UserGuide.htm in the docs folder? It explains all of the above. Please read it if you haven't.

If you need any more help though, just ask.

Paul

Link to comment
Share on other sites

I've had a closer look at the offsets for fuel. If you want to know how much fuel is in the plane (and possibly change the amount) you need to be looking at offsets starting at 0B74 and another block starting at 1244. (These are 4 bytes and so you need Integers in this case).

Paul

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.