Jump to content
Sign in to follow this  
Guest jkoifman

Receiving filename through VB .net

Recommended Posts

Guest jkoifman

How would I write a simple program that retreives the name of the last loaded flight file in VB .net?I've been trying for hours and cannot get past connecting to the simulator.The documentation given for visual basic is quite limited.Thanks!

Share this post


Link to post
Share on other sites
Guest DocMoriarty

An extremely short version of a program that will receive the FlightLoaded event (Ends after receiving one filename). Didn't try this in VS yet, just copied all the relevant stuff from one of my sources.Imports Microsoft.Flightsimulator.SimConnectModule VBReceiveFilenamePrivate Enum MyEventIDs FlightLoaded = 1End EnumPrivate WithEvents m_SC as SimConnectPrivate m_Bored as Boolean = TruePublic Sub Main() m_SC = New SimConnect("ZZZzzzZZzzZZZzZ", 0, 0, Nothing, 0) m_SC.SubscribeToSystemEvent(MyEventIDs.FlightLoaded, "FlightLoaded") Dim yawn as Integer = 50 While m_Bored m_SC.ReceiveMessage() System.Windows.Forms.Application.DoEvents() System.Threading.Thread.CurrentThread.Sleep(yawn) End While m_SC.Dispose()End SubPrivate Sub m_SC_OnRecvEventFilename(ByVal sender As Microsoft.FlightSimulator.SimConnect.SimConnect, ByVal data As Microsoft.FlightSimulator.SimConnect.SIMCONNECT_RECV_EVENT_FILENAME) Handles m_SC.OnRecvEventFilename Select Case CType(data.uEventID, MyEventIDs) Case MyEventIDs.FlightLoaded MsgBox("Flight loaded: " & data.szFileName) ' This breaks the main loop m_Bored = False End SelectEnd SubEnd Module

Share this post


Link to post
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
Sign in to follow this  

  • Tom Allensworth,
    Founder of AVSIM Online


  • Flight Simulation's Premier Resource!

    AVSIM is a free service to the flight simulation community. AVSIM is staffed completely by volunteers and all funds donated to AVSIM go directly back to supporting the community. Your donation here helps to pay our bandwidth costs, emergency funding, and other general costs that crop up from time to time. Thank you for your support!

    Click here for more information and to see all donations year to date.
×
×
  • Create New...