Announcement

Collapse
No announcement yet.

udt form vb to pb

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • udt form vb to pb

    Hi, I want to modify an array that has been defined in vb using pb.
    Everything works fine but now I changed my code and I get an error in vb 'Byref type argument mismatch'.
    I don't see why! Any idea???

    In the first version I had an array...

    Public ObjectInfo(1000) As long

    The version with the error is...

    Public Type ObjectData
    Area As Long
    Ortho As Long
    Diago As Long
    LongestChord As Long
    Status As Long
    End Type

    Public ObjectInfo(1000) As ObjectData


    Thanks for any help

    ------------------

  • #2
    Thierry, can you post more complete source code please? it'll make it easier for people to help you
    Best regards,
    Wayne


    ------------------
    -

    Comment


    • #3
      Without seeing more code, my best guess is that the function
      declare is invalid. Your first iteration was an array of longs,
      your second, an array of structures (udts). Check your function
      declaration.

      Cheers,
      Cecil

      ------------------

      Comment


      • #4
        Is the public structure (udt) defined at Module-level?
        You cannot declare a public structure in a Form/class module.


        ------------------
        Fred
        mailto:[email protected][email protected]</A>
        http://www.oxenby.se

        Fred
        mailto:[email protected][email protected]</A>
        http://www.oxenby.se

        Comment


        • #5
          In vb, at module level I have:

          Declare Sub SetObjectInfoArray Lib "c:\agristo\pb\iplib" Alias "SETOBJECTINFOARRAY" (ByRef hObjectInfo As Long)

          Public Type ObjectData
          Area As Long
          Ortho As Long
          Diago As Long
          LongestChord As Long
          Status As Long
          End Type

          Public ObjectInfo(1000) As Long

          This compiles fine, but when I change this to 'ObjectInfo(1000) as ObjectData' I get a compiler-error!

          Any idea?




          ------------------

          Comment


          • #6
            If you are passing this array to the DLL (by passing the 1st element BYREF), did you change the "AS LONG" parameter in the DECLARE to "AS ObjectData" ? Obvopusly the DLL would have to be expecting the structure BYREF too (or more likely receiving a BYVAL DWORD that can be then allocated to a UDT pointer).

            ------------------
            Lance
            PowerBASIC Support
            mailto:[email protected][email protected]</A>
            Lance
            mailto:[email protected]

            Comment


            • #7
              Thanks Lance, now that you say it is seems obvious ;-)
              I didn't pass the structure byref! I thought since the structure consist of
              longs that I had to set the parameter in the declare also as long.

              'simple things' aren't always as simple as it seems ;-)

              ------------------

              Comment

              Working...
              X