Confusion!

I think I have confused at least half the class with my explanation of parameter passing! Or at least maybe not my explanation but certainly my attempted explanation of the NAB type question.

Let me try and simplify it again:

Call by value means a copy of a variable is used in a sub-routine. If it changes the variable, only the copy is changed, not the original.

Call by reference uses the original variable (by referring to the address of the variable rather than a copy). If it changes, then the original is changed also.

If you understand that then you are probably fine! The NAB question was confusing as it lacked some important details.

The other thing we did to day was functions. The important thing about them is that they produce a value. For example random produces a random number.

functinos.jpg

Here is the powerpoint on parameter passing:

parameter-passing.jpg

Advertisements

Tags:

One Response to “Confusion!”

  1. hobbylobby Says:

    I find that I almost never pass by value.

    I believe that Microsoft agrees that it’s more efficient to pass by reference, correct?

    another reason for ByRef’ing everything: I hardly ever pass values that I plan to change only locally.

    If I wanted to change a value locally, I think I would declare a variable and immediately use it – then let vb dispose of it when it’s out of scope.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: