Results 1 to 3 of 3

Thread: Qs.: What is ByVal & ByRef?

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jan 2007
    Location
    Iran
    Posts
    237

    Qs.: What is ByVal & ByRef?

    Hi,
    What is ByVal & ByRef(VB)?
    Very thans,
    Y.P.Y

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

    Re: Qs.: What is ByVal & ByRef?

    ByVal and ByRef are modifiers used in function parameters.

    ByVal means "pass by value". Marking a parameter to be passed by value means that a copy of it is made and passed to the function. The function can modify it, but it won't affect the original variable.

    ByRef means "pass by reference" and is the default mode. Passing a variable by reference means that instead of a copy of the variable, the function receives a reference to it. It thus may modify the original variable.

    When calling a function with ByRef parameters, you may explicitly specify the ByVal modifier on any of the arguments that you send it. This will force a copy of the variable to be made. You cannot, however, explicitly specify ByRef on a ByVal parameter.

    You should also note the behaviour of ByVal with objects. Since object variables are all references anyway, specifying ByVal on these means that a copy of the reference is made, not a copy of the object. Your original reference is safe, but the function can still modify members of the object itself.

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Jan 2007
    Location
    Iran
    Posts
    237

    Re: Qs.: What is ByVal & ByRef?

    Very thanks Penagate
    Y.P.Y

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