0 To in arrays..


A new feature in Vb.NET 2005, requested by your’s truely, is the ability to include the “0 To ” in array declarations.   Whe nI asked for this feature though, I aksed for it to be a project level switch, such that the “0 To ” would always be included for you, and ideally be grey to symbolize you can’t edit that part.


So the outcome would be code such as :


 Dim myStrings(10) As String


would appear as:


  Dim myStrings(0 To 10) As String


The beauty of this is folks automatically know the declaration is 0 to upper bound. 


Now what got me blogging about this, is a recent article on migrating VBA to VB.NET on msdn.  If you scroll down to the section on arrays, you’ll see the author got it wrong and declared the array as if by count, not upperbound.  Perhaps this visual helper would have helped them out a bit.  it’s sad to see people get such simple stuff wrong, and really does cry out that a fix is needed… Oh well, maybe in orcas ……..



1 Comment so far

  1.   Matthew on April 11th, 2005          

    That is a great new feature! In VB 6, I always requested people put lower bounds in their declaration to save me unnecessary thinking. The same feature in VB.NET (even if the lower bound is fixed at 0) will once again save ‘unnecessary thinking’ and make code easier to read.