Announcement

Collapse
No announcement yet.

Want to make a multipurpose function in PB for VB.

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

  • Fred Oxenby
    replied
    Originally posted by Michael Meeks:
    Also, I have found that when using declares in VB that the
    Alias should be in all Captials. I have many examples that
    don't work, if I don't.
    Code:
    VB-DECLARE:
    Declare Function ReadIt Lib "MY.DLL" [b]Alias "ReadIt"[/b]()As Long
                                         !------------!=> this will VB remove from the declaration
    PB-FUNCTION:
    Function ReadIt [b]alias "ReadIt"[/b]()Export as long
    --
    VB will remove (in the declaration) any 'Alias' witch have same capitalisation as the function-name
    =========================
    VB-DECLARE:
    Declare Function ReadIt Lib "MY.DLL" Alias "READIT"() As Long
    PB-FUNCTION:
    Function ReadIt()Export as long
    Function ReAdIt()Export As Long
    Function readIt()Export As Long
    Function READit()Expotr As Long
    Function READIT()Export AS Long
    or any other capitalisation where the Alias-keyword is missing
    will be exported by PB/DLL as 
    Function [b]READIT[/b]() As Long

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




    [This message has been edited by Fred Oxenby (edited September 14, 2000).]

    Leave a comment:


  • Michael Meeks
    replied
    Hi,

    When calling a PB DLL from VB, I use strings to hold the data,
    because many times VB errors out in invalid expressions, and
    it something of a pain to ts!

    Strings are much easier to convert once they are passed between
    VB/PB and the speed is almost as fast! For example, I pass a
    zipcode as a string, converts to long, searches a db of 43,000
    records, returns everything as a string,
    (all within a second or two).

    Also, I have found that when using declares in VB that the
    Alias should be in all Captials. I have many examples that
    don't work, if I don't.

    <Declare Function ReadIt Lib "MY.DLL" Alias "ReadIt">

    I change this to read:
    Declare Function ReadIt Lib "MY.DLL" Alias "READIT"

    Mike


    ------------------
    mwm

    Leave a comment:


  • Edwin Knoppert
    replied
    This is for incomming parameters, not the return value(s)

    Again,

    VB uses 2 (or more)diff. declares
    In the VB app the correct declare is used to get the return value from a PB dword pointer.
    Based on the provided parameter (what), PB uses a double or string and passes it to the FUNCTION[]

    Declare Function ReadItSTRING Lib "MY.DLL" Alias "ReadIt" (ByVal What As Long ) As String
    Declare Function ReadItDouble Lib "MY.DLL" Alias "ReadIt" (ByVal What As Long ) As Double

    (Did not test Tom's ASM offset yet)

    Note that the string part is working.
    Only other types of return types won't work yet.

    Would be more perfect if i could use:
    Declare Function ReadItVariant Lib "MY.DLL" Alias "ReadIt" () As Variant




    ------------------
    [email protected]

    Leave a comment:


  • Michael Mattias
    replied
    See Dave Navarro's recent code in the Source Code Forum for a replacement for "PRINT USING."

    It's a darn clever use of a UNION to accept "any" parameters.

    You could apply it to this situation real easily and get rid of the assembly code.

    MCM




    ------------------
    Michael Mattias
    Racine WI USA
    [email protected]

    Leave a comment:


  • Want to make a multipurpose function in PB for VB.

    I want to return a double or string as dword like this

    PB:
    Code:
    Function ReadIt( ByVal what as Long ) Export As Dword
    
        Dim T       As String
        Dim DBL     As Double
        Dim Temp    As Dword
    
        Select Case What
        Case 0
    
         T = "1234"
    
         ! MOV EAX,  T
         ! MOV TEMP, EAX
         ! MOV DWORD T, 0
    
         FUNCTION = Temp
    
        Case 1
    
    'Example from PB but i need to set a double instead..
    
            DBL = 1234567
    
            ! mov AL, Byte Ptr rgb_value[0]
            ! xor AH, AH
            ! mov FUNCTION[0], AX
    
        End Select
    
    End Function
    
    VB:
    Declare Function ReadItSTRING Lib "MY.DLL" Alias "ReadIt" (ByVal What As Long ) As String
    Declare Function ReadItDouble Lib "MY.DLL" Alias "ReadIt" (ByVal What As Long ) As Double

    The Double part is not working (Not with the example above of course but i tried it with MKD$ etc.. )

    ???

    Or can use VB variants somehow?
    VB6<>PB6


    ------------------
    [email protected]
Working...
X