|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Procedures/FunctionsHopefully 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 wrote:
> Hopefully this list is newbie-friendly. I have a conceptual questions. I am Because you don't always need or want to return a value. There is> 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? nothing stopping you from always using a function. It's just sometimes it doesn't really make sense. -- Tom Shelton 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 > > 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 >> >> > >
C# vs. VB.NET: typing speed
About IDisposable.Dispose() Collection Sort Arraylist Problem Inherited Forms in VB.NET class code does not show 'inherits from...' Configuration in published program Mnemonics for Buttons with symbols on Determining if MS Word is running through VB code VB.net 1.0 to VB.net Express Edition Infuriating Icon Problem |
|||||||||||||||||||||||