Click here to Skip to main content
14,884,209 members
Home / Discussions / Visual Basic
   

Visual Basic

 
AnswerRe: Custom PaperSize Problem Pin
P P Vilsad6-May-07 5:34
MemberP P Vilsad6-May-07 5:34 
GeneralRe: Custom PaperSize Problem Pin
AmirAlilou6-May-07 21:15
MemberAmirAlilou6-May-07 21:15 
GeneralRe: Custom PaperSize Problem Pin
P P Vilsad7-May-07 3:03
MemberP P Vilsad7-May-07 3:03 
QuestionIs Multiple Exit points in a method wrong [modified] Pin
RichardBerry4-May-07 21:46
MemberRichardBerry4-May-07 21:46 
AnswerRe: Is Multiple Exit points in a meethod wrong Pin
Xandip4-May-07 22:59
MemberXandip4-May-07 22:59 
GeneralRe: Is Multiple Exit points in a meethod wrong Pin
RichardBerry4-May-07 23:16
MemberRichardBerry4-May-07 23:16 
AnswerRe: Is Multiple Exit points in a method wrong Pin
Kevin McFarlane5-May-07 3:52
MemberKevin McFarlane5-May-07 3:52 
AnswerRe: Is Multiple Exit points in a method wrong Pin
Dave Kreskowiak5-May-07 3:57
mveDave Kreskowiak5-May-07 3:57 
RichardBerry wrote:
1) Someone told me a function should have only one exit point - why is this?


A big reason is code maintainability. One way in, one way out. If the code has to be modified, you don't have to hunt down all the exit points in a function to make sure it's returning a good value.


RichardBerry wrote:
2) Is it bad practice to use the input to the function directly. In example below, I compare intInput to a constant (10).


Yes, it is, but not for the reason you think. The first thing a function should normally do, is validate the incomming data. This may require multiple tests on multiple parameters. It may also be helpful to put the validated data in local variables so you know that you're using validated data in the rest of the function code.


RichardBerry wrote:
3) As opposed to using 'Return True' or 'Return False' is it better to
use the function name - E.g. 'Test = False'


No, it's not. Quite the opposite. In some languages, including older versions of VB, you had to assign the return value to the function name. It's far more readable and maintainable to use a Return statement. The "assign to function name" method is still in there for backwards compatibility. I wish it would just go away...


Dave Kreskowiak
Microsoft MVP
Visual Developer - Visual Basic
     2006, 2007


GeneralRe: Is Multiple Exit points in a method wrong Pin
Paul Conrad5-May-07 5:18
professionalPaul Conrad5-May-07 5:18 
GeneralRe: Is Multiple Exit points in a method wrong Pin
Kevin McFarlane5-May-07 12:18
MemberKevin McFarlane5-May-07 12:18 
GeneralRe: Is Multiple Exit points in a method wrong Pin
Paul Conrad5-May-07 12:29
professionalPaul Conrad5-May-07 12:29 
GeneralRe: Is Multiple Exit points in a method wrong Pin
RichardBerry6-May-07 23:56
MemberRichardBerry6-May-07 23:56 
GeneralRe: Is Multiple Exit points in a method wrong Pin
Dave Kreskowiak7-May-07 1:16
mveDave Kreskowiak7-May-07 1:16 
QuestionTiff Image Pin
Ramuv4-May-07 21:44
MemberRamuv4-May-07 21:44 
Questionshortcut key Pin
Sonia Gupta4-May-07 20:48
MemberSonia Gupta4-May-07 20:48 
AnswerRe: shortcut key Pin
Rupesh Kumar Swami4-May-07 21:52
MemberRupesh Kumar Swami4-May-07 21:52 
QuestionRe: shortcut key Pin
Sonia Gupta4-May-07 22:32
MemberSonia Gupta4-May-07 22:32 
AnswerRe: shortcut key [modified] Pin
Rupesh Kumar Swami4-May-07 23:35
MemberRupesh Kumar Swami4-May-07 23:35 
GeneralRe: shortcut key Pin
Sonia Gupta5-May-07 0:52
MemberSonia Gupta5-May-07 0:52 
Questionimmediate window Pin
Sonia Gupta4-May-07 20:38
MemberSonia Gupta4-May-07 20:38 
AnswerRe: immediate window Pin
Xandip4-May-07 22:32
MemberXandip4-May-07 22:32 
QuestionRe: immediate window Pin
Sonia Gupta4-May-07 22:34
MemberSonia Gupta4-May-07 22:34 
AnswerRe: immediate window Pin
Xandip4-May-07 22:41
MemberXandip4-May-07 22:41 
AnswerRe: immediate window Pin
Dave Kreskowiak5-May-07 3:46
mveDave Kreskowiak5-May-07 3:46 
QuestionLogin Form Pin
Hakmeh Mohannad4-May-07 13:23
MemberHakmeh Mohannad4-May-07 13:23 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.