Results 1 to 11 of 11

Thread: ByRef ByVal Discrepancy

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jul 2000
    Location
    FeedMeTown, Ohio
    Posts
    176

    ByRef ByVal Discrepancy

    Not sure about this. According to VB5 Online help...

    ByRef Optional. Indicates that the argument is passed by reference. ByRef is the default in Visual Basic.

    According to Microsoft Website...

    ByVal is default.

    Which should I believe?
    Last edited by EZapps; Mar 22nd, 2004 at 09:32 PM.
    Never tie a rock to your ankle while randomly selecting stones to throw from high places.

  2. #2
    The picture isn't missing BuggyProgrammer's Avatar
    Join Date
    Oct 2000
    Location
    Vancouver, Canada
    Posts
    5,217
    byref is default.

    What link did it say either? (ie: post both links)
    Remember, if someone's post was not helpful, you can always rate their post negatively .

  3. #3
    Frenzied Member Shawn N's Avatar
    Join Date
    Dec 2001
    Location
    Houston
    Posts
    1,631
    If you're creating your fuctions, you should explicitly declare whether variables are passed ByRef or ByVal. It's a good habit to keep the guess work out.
    Please rate my post.

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Jul 2000
    Location
    FeedMeTown, Ohio
    Posts
    176
    Never tie a rock to your ankle while randomly selecting stones to throw from high places.

  5. #5
    The picture isn't missing BuggyProgrammer's Avatar
    Join Date
    Oct 2000
    Location
    Vancouver, Canada
    Posts
    5,217
    you were looking at .NET documentation.
    Remember, if someone's post was not helpful, you can always rate their post negatively .

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Jul 2000
    Location
    FeedMeTown, Ohio
    Posts
    176
    Shawn

    Thanks. I agree... especially since there seems to be a lot of discrepency within Microsoft itself.
    Never tie a rock to your ankle while randomly selecting stones to throw from high places.

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Jul 2000
    Location
    FeedMeTown, Ohio
    Posts
    176
    Buggy

    That brings up a good point. If the default values change (as per MS whim) and we don't explicitly declare ByRef or ByVal, will our software fail???
    Never tie a rock to your ankle while randomly selecting stones to throw from high places.

  8. #8

    Thread Starter
    Addicted Member
    Join Date
    Jul 2000
    Location
    FeedMeTown, Ohio
    Posts
    176
    To further explain...

    Please correct me if I'm wrong, as I am quite often. My understanding is that once compiled, the software is converted to machine language... subordient to the machine and operating system it resides on.

    If, by default, that operating system assumes ByVal (when not explicitly declared), what guarantees do I have that my program (written and compiled with VB5) will work on Windows 2003?
    Never tie a rock to your ankle while randomly selecting stones to throw from high places.

  9. #9
    Frenzied Member Shawn N's Avatar
    Join Date
    Dec 2001
    Location
    Houston
    Posts
    1,631
    Your OS has nothing to do with how variables are passed, in respect to BV or BR. Your software will more than likely either fail or product bad output if you meant to pass BV but passed BR or vice versa.

    I really really advise explicitly labeling your function decleration's parameters with either BV or BR.
    Please rate my post.

  10. #10

    Thread Starter
    Addicted Member
    Join Date
    Jul 2000
    Location
    FeedMeTown, Ohio
    Posts
    176
    Thanks Shawn...

    Your advice is well heeded. In the future, I'll pay more attention and leave less to chance.
    Never tie a rock to your ankle while randomly selecting stones to throw from high places.

  11. #11

    Thread Starter
    Addicted Member
    Join Date
    Jul 2000
    Location
    FeedMeTown, Ohio
    Posts
    176
    Oh... Thanks to you also Buggy...

    Your advice always seems solid!
    Never tie a rock to your ankle while randomly selecting stones to throw from high places.

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