I think I'm right in saying that VB, by default, passes arguments by reference. If you wanted an argument to be passed by value then you prefix it with the ByVal keyword.
____________________________________________________ $str = "sleep is good for you. sleep gives you the energy you need to function";
$Nstr = ereg_replace("sleep","coffee",$str); echo $Nstr;
Quite correct, Stretchwicster. Now, there's a bit of strangeness about all this when you are working with strings. Normally, when you pass an argument byval, you have two copies of the actual value, whereas if you pass byref, you have two references to the same copy of the actual value. However, If you pass a string argument byval, you are actually passing the value of the pointer to a string. The pointer, of course, is a reference. As such, if you get a byval string argument, you can use the reference that it represents to alter the values of the characters in the string, and have the changes visible to the calling context.
I better add something to that. VB fixes things internally so that byval and byref work with strings the same way as everything else. But try calling, say, GetWindowsDir from the WinAPI. When you pass a string, you pass byVal a null-terminated string and that string contains the windows directory after getwindowsdir is run.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.