Here's another example where VB.NET is easier than VB6. If you're joining
us late, Tuesday we covered how creating a user control is much easier in
VB.NET.....

http://news.devx.com/cgi-bin/dnewswe...em=44342&utag=

Wednesday, we saw how using a file open dialog is easier in VB.NET....

http://news.devx.com/cgi-bin/dnewswe...em=44447&utag=

Today, we'll switch to a completely different subject...language syntax.
Specifically, let's look at how VB.NET syntax for calling a procedure is
easier than in VB6. This example applies to both beginner and intermediate
programmers. Advanced programmers probably code them without even thinking
about it. OK, let's look at VB6 first...

In VB6, there are five separate rules (plus 2 special cases) for when you
use parenthesis around an argument list and when you don't. Let's go through
each rule, one at a time. I'll also provide an example of each because this
can kind of get confusing.

Rule 1....Calling a Subroutine with the Call Keyword. When calling a subroutine
using the Call keyword, you must use parenthesis around the parameter list.
Example....

Call MySub(Parm1, Parm2)

Failure to do so will cause a compile error.

Rule 2....Calling a Subroutine Without the Call Keyword. When calling a subroutine
without using the Call keyword, you cannot use parenthesis around the parameter
list. Example....

MySub Parm1, Parm2

If you mistakenly use parenthesis around the parameter list, you will get
a compile error.

Rule 3....Calling a Function, Storing the Return Value in a Variable. When
calling a function and you store the return value into a variable, you must
use parenthesis around the parameter list. For example.....

MyReturnValue = MyFunction(Parm1, Parm2)

Failure to do so will cause a compile error.

Rule 4....Calling a Function, Ignoring the Return Value. When calling a
function and you don't use the return value, you cannot use parenthesis.
For example....

MyFunction Parm1, Parm2

If you mistakenly use parenthesis around the parameter list, you will get
a compile error.

Rule 5....Calling a Function, Ignoring the Return Value Using the Call Keyword.
When calling a function, ignoring the return value and using the Call keyword
you must use parenthesis. For example....

Call MyFunction(Parm1, Parm2)

Failure to do so will cause a compile error.

Rule 6....Calling a Subroutine Without the Call Keyword But with Only One
Parameter (Special Case of Rule 2). When calling a subroutine that accepts
only one parameter, and you don't use the Call keyword, you can use a parenthesis.
However, the behavior now changes such that the parameter is passed by value
even if the parameter is declared in the subroutine by reference. Example...

MySub (Parm1)

This line of code will compile regardless of whether there are parenthesis,
however the behavior may be different (see above).

Rule 7....Calling a Function Without the Call Keyword But with Only One Parameter
Ignoring the Return Value (Special Case of Rule 4). When calling a function
that accepts only one parameter, and you don't use the Call keyword, you
can use a parenthesis. However, the behavior now changes such that the parameter
is passed by value even if the parameter is declared in the function by reference.
Example:

MyFunction (Parm1)

This line of code will compile regardless of whether there are parenthesis,
however the behavior may be different (see above).

Now, let's take a lot at VB.NET.

Rule 1....Always Use Parenthesis.

Examples:

MySub (Parm1 Parm2)
Call MySub(Parm1, Parm2)
MyReturnValue = MyFunction(Parm1, Parm2)
MyFunction(Parm1, Parm2)
Call MyFunction(Parm1, Parm2)
MySub(Parm1)
MyFunction(Parm1)

Forgetting to use the parethesis in VB.NET will not cause a compile error
because the VB.NET's IntelliSense.

OK, you be the judge. Which procedure calling syntax do you think is easier
and why?

/Pat