Home All Groups Group Topic Archive Search About
Author
12 Sep 2006 1:23 AM
Anil Gupte
Hopefully this list is newbie-friendly.  I have a conceptual questions. I am
learning VB and came across the description in a book I am using that
describes procedures vs. functions.  I understand the difference, but my
question would be - why use procedures at all if functions do everything
that procedures do, and in addition return a value?

Thanx,

Author
12 Sep 2006 2:00 AM
Tom Shelton
Anil Gupte wrote:
> Hopefully this list is newbie-friendly.  I have a conceptual questions. I am
> learning VB and came across the description in a book I am using that
> describes procedures vs. functions.  I understand the difference, but my
> question would be - why use procedures at all if functions do everything
> that procedures do, and in addition return a value?

Because you don't always need or want to return a value.  There is
nothing stopping you from always using a function.  It's just sometimes
it doesn't really make sense.

--
Tom Shelton
Author
12 Sep 2006 2:04 AM
Miro
Anil,

I was exactly in your boat about 3 weeks ago or a tad more.
I am new to vb.net and posted the same question.

To answer your question quick, you are correct.  A Function is the same as a
Sub except a Function
returns a value.

===now for the long

I come from a programming concept where everything is programmed in a
function and always returns
a value of .T. or something else if needed.  So I asked,
why not make everything a function instead of using subs and functions.

The answer given to me ( and I cant find the old post here ) is that you
can, but there is no point.
A Sub procedure can be changed to a function very simply if it is required
to be for one ( which was an answer given to me ).

It is just is simpler and proper programming.
I have since then tried to program with subs, and functions when needed.  It
does seem cleaner reading code following
some VB standards.

But I think you might be coming from the same place I was.  Always a
function.
Hard to break the habit, but im happier for it.

M.

Show quoteHide quote
"Anil Gupte" <anil-l***@icinema.com> wrote in message
news:%23hm1gog1GHA.3464@TK2MSFTNGP03.phx.gbl...
> Hopefully this list is newbie-friendly.  I have a conceptual questions. I
> am learning VB and came across the description in a book I am using that
> describes procedures vs. functions.  I understand the difference, but my
> question would be - why use procedures at all if functions do everything
> that procedures do, and in addition return a value?
>
> Thanx,
> --
> Anil Gupte
> www.keeninc.net
> www.icinema.com
>
>
Author
12 Sep 2006 8:43 AM
Anil Gupte
Thanx Miro and Tom!  In other words "Yes! We have no bananas!" :-)

Best,
Show quoteHide quote
"Miro" <miron***@golden.net> wrote in message
news:eaxlH%23g1GHA.3476@TK2MSFTNGP04.phx.gbl...
> Anil,
>
> I was exactly in your boat about 3 weeks ago or a tad more.
> I am new to vb.net and posted the same question.
>
> To answer your question quick, you are correct.  A Function is the same as
> a Sub except a Function
> returns a value.
>
> ===now for the long
>
> I come from a programming concept where everything is programmed in a
> function and always returns
> a value of .T. or something else if needed.  So I asked,
> why not make everything a function instead of using subs and functions.
>
> The answer given to me ( and I cant find the old post here ) is that you
> can, but there is no point.
> A Sub procedure can be changed to a function very simply if it is required
> to be for one ( which was an answer given to me ).
>
> It is just is simpler and proper programming.
> I have since then tried to program with subs, and functions when needed.
> It does seem cleaner reading code following
> some VB standards.
>
> But I think you might be coming from the same place I was.  Always a
> function.
> Hard to break the habit, but im happier for it.
>
> M.
>
> "Anil Gupte" <anil-l***@icinema.com> wrote in message
> news:%23hm1gog1GHA.3464@TK2MSFTNGP03.phx.gbl...
>> Hopefully this list is newbie-friendly.  I have a conceptual questions. I
>> am learning VB and came across the description in a book I am using that
>> describes procedures vs. functions.  I understand the difference, but my
>> question would be - why use procedures at all if functions do everything
>> that procedures do, and in addition return a value?
>>
>> Thanx,
>> --
>> Anil Gupte
>> www.keeninc.net
>> www.icinema.com
>>
>>
>
>