Results 1 to 9 of 9

Thread: Use of the CALL keyword

  1. #1

    Thread Starter
    Addicted Member sigid's Avatar
    Join Date
    May 2006
    Location
    Massachusetts, USA
    Posts
    182

    Use of the CALL keyword

    This is a general question regarding the use of the CALL keyword...

    I'm not referning to external procs, but rather to internal or intrinsic procs.

    I have read that the use of the keyword CALL is considered to be obsolete and to have detrimental effects on the operation of the application.

    Does anyone have any specific insight as to whether this is right or wrong, and what these effects might be?

    Simple minded Example:
    Msgbox "OK"
    vs
    CALL Msgbox("OK")

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Use of the CALL keyword

    I have not known Call to have a determental effect.

    It is included with the language more for backward compatibility than practical use however.

  3. #3
    PowerPoster gavio's Avatar
    Join Date
    Feb 2006
    Location
    GMT+1
    Posts
    4,462

    Re: Use of the CALL keyword

    Please check Call statement thread.

  4. #4
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: Use of the CALL keyword

    The difference is purely syntactic.

    In VB6 calling a procedure without trapping its return value means you do not use the parentheses around the argument list.
    VB Code:
    1. MySub arg1, arg2
    2. ' vs.
    3. ret = MyFunc(arg1, arg2)

    Call allows you to call a Sub, or call a function without trapping its return value, and use the argument parentheses as well.
    VB Code:
    1. Call MySub(arg1, arg2)

    Make of it what you wish, I think it's fairly pointless.

    BTW in VB.NET both types of procedure call can be effected using the argument parentheses now, so in VB.NET the Call keyword truely is obsolete.

  5. #5
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Use of the CALL keyword

    Quote Originally Posted by penagate
    BTW in VB.NET both types of procedure call can be effected using the argument parentheses now, so in VB.NET the Call keyword truely is obsolete.
    As it probably should have been in VB6.

  6. #6
    Frenzied Member TheBionicOrange's Avatar
    Join Date
    Apr 2001
    Location
    Cardiff, UK
    Posts
    1,818

    Re: Use of the CALL keyword

    I'e noticed this in the past, and never really knew the difference between

    VB Code:
    1. Call MyProc(x,y)

    as opposed to

    VB Code:
    1. MyProc x,y

    I think some people like to use it as it "stands out" a bit more that the code is calling another routine.

  7. #7
    Fanatic Member
    Join Date
    Aug 2005
    Location
    South Africa
    Posts
    760

    Re: Use of the CALL keyword

    What about if you want to call a process without passing it any arguments, would it be better to use Something() than to use Call Something?
    If I helped you out, please consider adding to my reputation!

    -- "The faulty interface lies between the chair and the keyboard" --

    VB6 Programs By Me:
    ** Dictionary, Thesaurus & Rhyme-Generator In One ** WMP Recent Files List Editor ** Pretty Impressive Clock ** Extract Firefox History **

  8. #8
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Use of the CALL keyword

    Quote Originally Posted by shirazamod
    What about if you want to call a process without passing it any arguments, would it be better to use Something() than to use Call Something?
    It doesn't matter. Both of these will execute whatever code is in the Something Sub
    VB Code:
    1. Private Sub Command1_Click()
    2. Something
    3. End Sub
    4.  
    5. Private Sub Command1_Click()
    6. Call Something
    7. End Sub

  9. #9
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: Use of the CALL keyword

    Apart from the fact that you can't actually do Something(), only Something, like I said there's no difference.

    In VB.NET, and other languages, it would be Something(), yes.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width