Results 1 to 13 of 13

Thread: what does "call" do?

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Dec 2000
    Posts
    135
    Whats the diffrence between "CALL sub1" and just "sub1"

  2. #2
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    the only thing I know of is that with Call, you need to pass parameters like :

    Call Sub1("Hello")

    as with simply saying "Sub1" its just :

    Sub1("Hello")
    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  3. #3
    Guest
    There is no differnce. Call is an optional keyword that was once used in the old days of Basic.

  4. #4
    Guest
    call can still b useful sometimes tho with things like msgbox coz u dont have to use a variable when u dont need to know what they clicked

  5. #5
    Guest
    if you don't need to know what they click then just don't use Parentheses.
    ex:
    MsgBox "This Work Just Fine", vbOKOnly

  6. #6
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    its good for readability...say you've just inheirited a project from some one and you come across this...
    Code:
    makeBacon
    The first thing I would think is what the f*** is this supposed to be? Now if it was a small amount of code, I could look through and see a sub or function called makeBacon, but let's say there's 400 lines of code? Do you what to go looking through the entire app for "makeBacon"? I wouldn't... so if you use:
    Code:
    Call makeBacon
    you know you're dealing with a procedure of some sort...
    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  7. #7
    Guest
    That is a very good point

  8. #8
    Guest
    i didt know u could do msgboxes like that

    !!!!



    But anyway, as to the people that say use call for readability, whats wrong with comments?

  9. #9
    PowerPoster Lethal's Avatar
    Join Date
    Oct 2000
    Location
    Ohio
    Posts
    2,496
    I tend to use "call" in all of my projects, for sheer readability.

  10. #10
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    ok, on comments...
    Code:
    makeBacon 'this calls the makeBacon subroutine
    do you want to have to do this for every occasion that you call makeBacon? it doesn't seem very practical to me...
    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  11. #11
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    thanks for the support Lethal
    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  12. #12
    Fanatic Member
    Join Date
    Nov 2000
    Location
    Sydney Australia
    Posts
    804
    Although readability is a very good point and I use it where possible, I don't think you use call to call a function and return a value. So call can only be used when you call a sub or a function where you are not interested in the result. If you want to return a value from the function you cannot use call.

    E.g

    Call msgbox("Confirm",vbyesno) 'doesn't return a value
    msgbox ("confirm",vbyesno) 'returns a value

  13. #13
    PowerPoster Lethal's Avatar
    Join Date
    Oct 2000
    Location
    Ohio
    Posts
    2,496
    i see what your saying it wouldn't make sense to do this:
    Code:
    Dim X as Integer
    x = Call MsgBox "Blah Blah Blah"
    Times like this you make the exception
    By the way, no problem Crypt...., great minds think alike..hehe

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