Announcement

Collapse
No announcement yet.

PBDLL Quad to VB. Need quick answer Please!

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

  • Cecil Williams
    Guest replied
    Ben,

    To follow up on what Eric said:
    Code:
    Type LARGE_INTEGER
        LowPart As Long
        HighPart As Long
    End Type
    I'm not a Visual Basic expert but it actually provides a 64-bit integer
    type called "Currency" unless I'm mistaken.

    The following is from MSDN:

    "But, you say, Currency isn’t an integer type, it’s a fixed-point type.
    Well, yes, but the bits are the same. It’s just that behind the scenes,
    COM Automation is moving a decimal point four places to the left on
    all currency integers. All you have to do to display a Currency value
    as a true integer is multiply by 10,000 (or use the CURRENCY-MULTIPLIER
    type library constant)".

    This is probably the best approach.

    Hope this helps!!!!!

    Cheers,
    Cecil

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


    [This message has been edited by Cecil Williams (edited August 28, 2001).]

    Leave a comment:


  • Eric Pearson
    replied
    Ben --

    If you can't change the QUAD to a LONG in the DLL, is it safe to assume that the return value is (or can be) too large to fit in a LONG? If so, it could be disasterous to try to use a LONG because it could overflow and produce incorrect results. So my first question is "are you sure you want to do that?"

    If there is some other reason you can't change it (maybe you don't have the source code?) you could probably use the Win32 LARGE_INTEGER structure in your VB program, which is compatible with a PowerBASIC QUAD. You could simply declare the function (in your VB program) AS LARGE_INTEGER, then use the elements of the UDT to obtain the value for VB to use.

    -- Eric


    ------------------
    Perfect Sync Development Tools
    Perfect Sync Web Site
    Contact Us: mailto:[email protected][email protected]</A>

    [This message has been edited by Eric Pearson (edited August 28, 2001).]

    Leave a comment:


  • Gregery D Engle
    replied
    If you aren't doing any mathmatical calculations in VB you can
    always pass a string byref to the function.

    ------------------
    -Greg

    Leave a comment:


  • Ben Clark
    replied
    I can't change it to a long.
    The value being returned from PB/DLL is 8 bytes long.

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

    Leave a comment:


  • Gregery D Engle
    replied
    VB doesn't support 64 bit variables.

    I would recommend you changing it to a long
    ------------------
    -Greg

    [This message has been edited by Gregery D Engle (edited August 28, 2001).]

    Leave a comment:


  • Ben Clark
    started a topic PBDLL Quad to VB. Need quick answer Please!

    PBDLL Quad to VB. Need quick answer Please!

    I have recently inherited a peace of code that needs repair.
    One of the problems is that a PB/DLL function is returning a
    QUAD variable when called from VB.
    The calling VB function is putting the result into a Long variable.
    How can I return a QUAD value from PBDLL to VB.

    PBDLL:

    Function Test() EXPORT AS QUAD
    Function = SomeQUADValue
    End Function

    VB: Declare Test Lib"blaBla.dll" Alias "Test"() as long
    Sub VBTest()
    Dim X as Long <<< What should this variable type be.

    X = Test()

    End Sub


    ------------------
Working...
X