Question Weirdo type conversion error

SmokingCookie

Member
Joined
Mar 26, 2009
Messages
8
Location
Netherlands
Programming Experience
Beginner
Hi,

It seems my VB.NET (console) application has trouble seeing that a structure is used locally. Below, I have posted a few pieces of code.

VB.NET:
        'hSimConnect has been created properly
        hSimConnect.AddToDataDefinition(DEFINITION_1,"Kohlsman setting hg","inHg",SIMCONNECT_DATATYPE.SIMCONNECT_DATATYPE_FLOAT32,0,0)
        hSimConnect.RequestDataOnSimObject(RequestId,DefineId,SimConnect.SIMCONNECT_OBJECT_ID_USER,SIMCONNECT_PERIOD.ONCE,0,0,0,1)
        Dim POS As SIMCONNECT_DATA_INITPOSITION ' This is the structure passed to AICreateNonATCAircraft()
        POS.Airspeed = 300
        POS.Altitude = PlayerAlt
        POS.Bank = 0
        POS.Heading = PlayerHDG
        POS.Latitude = LAT
        POS.Longitude = LON
        POS.OnGround = 0
        POS.Pitch = 0
        PrintNewLine()
        ' "POS" parameter in the next line triggers the error
        hSimConnect.AICreateNonATCAircraft("Boeing 737-800 Paint6","N01000",POS,REQUESTID)
Structure definition:
VB.NET:
Structure SIMCONNECT_DATA_INITPOSITION
    Public Latitude As Double
    Public Longitude As Double
    Public Altitude As Double
    Public Pitch As Double
    Public Bank As Double
    Public Heading As Double
    Public OnGround As Double
    Public Airspeed As Double 'DWord equivalent?
End Structure
It all seems to work properly, until the call to AICreateNonATCAircraft is made. I get the following error:

Value of type 'ConsoleApplication1.SIMCONNECT_DATA_INITPOSITION' cannot be converted to 'Microsoft.FlightSimulator.SimConnect.SIMCONNECT_DATA_INITPOSITION'.
Could anyone please help me on this one?
Thanks in advance.
 
'DWord equivalent?
I don't know the structure you're using, but Dword is a 32-bit unsigned integer, ie UInteger.
The error message says you have to use the SIMCONNECT_DATA_INITPOSITION type of Microsoft.FlightSimulator.SimConnect namespace, though, and not define your own type with same name.
 
Okay, it seems to be fixed now. I now use:

Dim POS As Mocrosoft.FlightSimulator.SimConnect.SIMCONNECT_DATA_INITPOSITION. Works fine :)
 
Back
Top