By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,353 Members | 1,555 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,353 IT Pros & Developers. It's quick & easy.

Procedures/Functions

P: n/a
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
Sep 12 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a

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

Sep 12 '06 #2

P: n/a
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" <an*******@icinema.comwrote in message
news:%2****************@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


Sep 12 '06 #3

P: n/a
Thanx Miro and Tom! In other words "Yes! We have no bananas!" :-)

Best,
--
Anil Gupte
www.keeninc.net
www.icinema.com

"Miro" <mi******@golden.netwrote in message
news:ea****************@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" <an*******@icinema.comwrote in message
news:%2****************@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



Sep 12 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.