We need you!

We're working hard on the next version of Developer Fusion. Let us know what you think we should be up to!

Members

Technology Zones

Articles

Hosted By

MaximumASP

Info

[42] Performance Issues

Last post 09-29-2005 8:20 PM by MahR. 2 replies.
Page 1 of 1 (3 items)
Sort Posts: Previous Next
  • 01-01-1999 12:00 AM

    [42] Performance Issues

    This thread is for discussions of Performance Issues.

    • Post Points: 0
  • 03-21-2002 9:09 AM In reply to

    Use of ByRef and ByVal

    This posting is specifically a response to James Cowleys suggestion that using ByVal is quicker than using ByRef.  This is only true when calling an out-of-process server (i.e. and ActiveX EXE).  VB is designed to pass all parameters ByRef, which means that everything is passed as a 32-bit pointer.  When passing ByVal VB copies the contents of the parameter into temporary space and then passes a 32-bit pointer to the temporary space.  This means that, counter-intuitively, it is slower passing a long ByVal than it is ByRef.  
    When calling an out-of-process server OLE must marshal a copy of your parameter into the address space of the routine you are calling and then, if it is ByRef, copy it back afterwards.  This is probably the only occasion that passing ByRef is slower.
    Generally ByVal should be reserved for occasions when the routine is going to change the contents of the variable and the calling routine will be affected by the change.  At the very least use ByRef for all strings and variants.
    • Post Points: 0
  • 09-29-2005 8:20 PM In reply to

    • MahR
    • Top 25 Contributor
    • Joined on 08-27-2004
    • Guru
    • Points 3,530

    Once Again!

    And once again a greate article by james!
    Mohammad Adil Hussain Raza
    VB6, HTML, ASP Developer, Graphic Designer
    For Urdu Active-X Controls: Click Here
    ----------------------------------------------
    Translation of word "Islam" in English is "Peace".
    ----------------------------------------------
    • Post Points: 0
Page 1 of 1 (3 items)