Register | Login 
Forum  
SearchForum Home
     
  Study Groups  VB.NET Key Points  Ch 3: Control F...
 Ch 3: Control Flow and Error Handling
 
 3/19/2006 10:03:48 PM
AlGonzalez
76 posts
nomadicview.blogspot.com/


Ch 3: Control Flow and Error Handling
Points of Interest/Suggestions
  • Pg 92: Can pass a variable by ByVal even if the parameter is defined ByRef by enclosing in parantheses.
  • Pg 96: Optional parameters are not CLS compliant
  • pg 100: Avoid Microsoft.VisualBasic namespace by removing reference to Microsoft.VisualBasic.dll assembly
  • pg 100: [Suggestion] Use System.Environment.NewLine instead of vbCrLf
  • pg 103: [Suggestion] Use System.Diagnostics.Process instead of Shell

Al Gonzalez
P.S. Solutions, Inc.
http://www.linkedin.com/in/algonzalez
 3/19/2006 11:45:37 PM
rcasebere
3 posts


Re: Ch 3: Control Flow and Error Handling
1. Do .... Loop more flexible than For ... Next
2. Objects can be passed by value only by copying them yourself
3.VB arrays are passed by reference
4. Don't throw exceptions for common occurrences, just use with truly exceptional conditions.
5. The IDisposable interface method Dispose and the using keyword can help the CLR in freeing up unneeded resources.
 3/20/2006 9:25:35 PM
possum
2 posts


Re: Ch 3: Control Flow and Error Handling
K, me and Dave cheated and worked together.    (This is Sarah btw, aka possum)

1.  Don't throw exceptions for relatively common errors.
2.  When using Select Case blocks, place the more frequent cases near the top of the block.
3.  In a For loop, use the Int or Long types for controlling variables.
4.  VB 2005 has a Continue For keyword that allows you to go to the next iteration of the loop.  That's cool because it's like the FoxPro "Loop" command and we all know that FoxPro is the most uber language. 
5.  If you want to pass a reference type to a procedure and be sure that you don't screw up the original, make a copy of it first.  Don't just pass ByVal. 


 3/20/2006 10:07:36 PM
DanTaylor
3 posts
Oriskany.net


Re: Ch 3: Control Flow and Error Handling
 Modified By DanTaylor  on 3/20/2006 10:07:57 PM)
  • New 2005 Continue Keyword within a loop enables you to jump to the next iteration of the loop.  Don't have to put an IF...End If Block to skip remaining statments.
  • For Next Loops
      If you need to increment a  floating point quantity  scale the start and end values by a factor of 10x so you can use an integer or long to control the loop.  This will avoid unexpected rounding of the control varaialble thus decreasing the expected iterations.
  • Iterating an array
      When working with an array a For Next Loop is faster than a For Each Loop.
  • Exiting an outer loop from the Inner Loop
      If you have nested loops and you want to exit the outer loop from the inner loop use different kinds of loops.  Example:
    For I as ...
        Do While ...
            Exit For  (This will exit outer loop)
       End While
    Next
  • An object reference passed by value does not create a copy of the object it creates a copy of the opbject reference.
 3/22/2006 5:08:42 PM
mike19841
3 posts


Re: Ch 3: Control Flow and Error Handling
a bit last minute, but i made it...

1) While loops should be replaced with Do While, and never use GoTo.
2) An object passed ByVal can still have its properties modified by the calling code. P.93
3) Throwing exceptions is costly and should be limited to rare occasions.
4) Removing Integer Overflow checks can increase performance.
5) Remember to Dispose resources after using them. Use a finally to be sure its Disposed.
  Study Groups  VB.NET Key Points  Ch 3: Control F...

Copyright (c) 2008 GSP Developers
Walling Info Systems | Terms Of Use | Privacy Statement