January 12, 200719 yr 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!
January 20, 200719 yr 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
Create an account or sign in to comment