No announcement yet.

What VB variable is compatible with a DWORD?

  • Filter
  • Time
  • Show
Clear All
new posts

    What VB variable is compatible with a DWORD?

    What VB variable is compatible with a DWORD?

    Thank you,
    Ryan M. Cross
    Webmaster FlexiFish Inc. UK
    Likuid Creations Inc.
    Thank you,
    Ryan M. Cross

    As far as I know I think a LONG is about as close as
    you will get. The LONG is signed (+/-) in VB whereas the
    DWORD is unsigned (+) in PB.

    Paul Squires
    [email protected]
    Paul Squires
    FireFly Visual Designer (for PowerBASIC Windows 10+)
    Version 3 now available.


      VB numeric data-types:
      INTEGER (2 bytes): -32,768 to 32,767
      LONG (4 bytes): -2,147,483,648 to 2,147,483,647
      SINGLE-precision-floating-point (4 bytes): -3.402823E38 to -1.401298E-45 for negative values, 1.401298E-45 to 3.402823E38 for positive values
      DOUBLE-precision-floating-point (8 bytes): -1.7976931344862315D308 to -4.94066D-324 for negative values, 4.94066D-324 to 1.797693134862315D308 for positive values
      CURRENCY-scaled-integer (8 bytes): -922337203685477.5808 to 922337203685477.5807

      but if youre like me and cant add up beyond 10, just stick to integers <grin>




        I would be very careful in trying to stuff a DWORD into a
        LONG. A Double Word is 32 bits (4 bytes), unsigned
        0 to 4,294,967,295 while a LONG is 2,147,483,647 on the
        positive side.

        For the most part you may be able to get by, BUT!!!!!!!!!




          Surly you could pass a long!

          But if you know that your app is being called by VB then use a check. If the number is positive then it will fit, and if negative then convert (assumably with the two's compliment rule)
          even if a negative is passed your dword will see it as a positive, but the area you need to be carefull of is passing a number too large for a long from a dword and having VB think it is negative. that could cause problems depending on what you are doing.

          Better still

          Test it! in the environment that it has to work in and most importantly Comment and document so people know what you've done.


          Paul Dwyer
          Network Engineer
          Aussie in Tokyo
          (Paul282 at VB-World)



            I am going to take a completely different stab at answering your question.
            Since you didn't say what prompted your question, I will consider what
            VB can pass to PB in the form of a DWORD.

            If you pass an ARRAY from VB to PB by reference as:

            call PBDLLroutine(MyArray())

            Then PB would read the array as:

            SUB PBDLLroutine ALIAS "PBDLLroutine" (MyArrayHeader as DWORD) EXPORT
            DIM MyArrayDim as LONG
            DIM MyArrayAddr as DWORD

            MyArrayDim = vbArrayUBound(MyArrayHeader,1)
            MyArrayAddr = vbArrayFirstElem(MyArrayHeader)
            DIM MyArray(MyArrayDim) AT MyArrayAddr

            So VB itself uses DWORD values, but it doesn't give us an equivilant
            data type to use.


            John Kovacich
            Ivory Tower Software


              You can always.....

              DWORDval = BITS???(LongVal)

              Of course, this only works on the PB side.

              Michael Mattias
              Tal Systems (retired)
              Port Washington WI USA
              [email protected]