How to Subscribe to the Facilities List using SimConnect

Imports Microsoft.FlightSimulator.SimConnect
 
Public Class frmMain
    Friend FSXFacilityAirport As New SIMCONNECT_DATA_FACILITY_AIRPORT
 
Friend Enum DATA_REQUESTS
   FACILITY_LIST = 0
End Enum
 
 
Friend fsx_simconnect As SimConnect
Friend Const WM_USER_SIMCONNECT As Integer = &H402
 
Private Sub FSXConnect()
If fsx_simconnect Is Nothing Then
   Try
       fsx_simconnect = New SimConnect("FSX", Me.Handle, 1026, Nothing, 0)
       SetupEventHandlers()
       SubscribeFacilityList()
   Catch ex As Exception
 
   End Try
    End If
End Sub
 
Friend Sub SubscribeFacilityList()
fsx_simconnect.SubscribeToFacilities(Microsoft.FlightSimulator.SimConnect.SIMCONNECT_FACILITY_LIST_TYPE.AIRPORT, DATA_REQUESTS.FACILITY_LIST)
End Sub
 
Friend Sub UnSubscribeFacilityList()
fsx_simconnect.UnsubscribeToFacilities(Microsoft.FlightSimulator.SimConnect.SIMCONNECT_FACILITY_LIST_TYPE.AIRPORT)
End Sub
 
Friend Sub SetupEventHandlers()
    AddHandler fsx_simconnect.OnRecvAirportList, New SimConnect.RecvAirportListEventHandler(AddressOf fsx_simconnect_OnRecvAirportList)
End Sub
 
Private Sub fsx_simconnect_OnRecvAirportList(ByVal sender As SimConnect, ByVal recEvent As SIMCONNECT_RECV_AIRPORT_LIST)
Select Case recEvent.dwRequestID
   Case DATA_REQUESTS.FACILITY_LIST
       For i As Integer = 0 To recEvent.dwArraySize - 1
           FSXFacilityAirport = CType(recEvent.rgData(i), SIMCONNECT_DATA_FACILITY_AIRPORT)
           msgbox(FSXFacilityAirport.Icao)
       Next
End Select
End Sub
 
Protected Overrides Sub DefWndProc(ByRef m As Message)
If m.Msg = WM_USER_SIMCONNECT Then
    If fsx_simconnect IsNot Nothing Then
        fsx_simconnect.ReceiveMessage()
    End If
Else
    MyBase.DefWndProc(m)
End If
End Sub
 
End Class