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

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.