Sign in to follow this  
Guest jkoifman

Receiving filename through VB .net

Recommended Posts

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
Help AVSIM continue to serve you!
Please donate today!

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