-
Aug 4th, 2010, 03:02 AM
#1
Thread Starter
Hyperactive Member
-
Aug 4th, 2010, 03:31 AM
#2
Re: newbie help
ByVal means to pass by value. This means a copy of the variable is sent to the function. ByRef means pass by reference. A "pointer" to the variable is sent to the function, so if you assign a new value to the passed parameter in the called function, the variable from the calling function is changed, too. Because ByRef parameters are just "pointers", the variable datatype must be an exact match. When you pass variables ByVal the dataype doesn't have to match because VB does implicit coercion.
-
Aug 4th, 2010, 04:12 AM
#3
Thread Starter
Hyperactive Member
Re: newbie help
Thanks for the reply Ellis
So in Byval values can be changed and in Byref can't?
can both Byref and Byval be used in the same user-defined function??
like this..
Code:
Private function Add(Byref a as integer, Byval b as integer)
if so, will u explain it?
-
Aug 4th, 2010, 05:55 AM
#4
Re: newbie help
All values can be changed, the difference is that changes to ByVal parameters get discarded once the function ends while changes to ByRef parameters are saved even after the function ends.
Yes, both types can be used in the same function.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|