Abbreviating My VB Code

by chris 12/12/2007 12:06:49 AM

While ignoring pressure from peer developers, I have chosen to stick with VB.NET as my development platform.  Almost everything I work on can be done with VB.NET, including converting those really handy C# code bits into VB.NET.  That being said, the other day I ran across a hand tip that will definitely make my life easier when writing code.  When writing a for loop statement I can nest the declaration in the For Next syntax.

For example, in the past I would write out a For Next statement like this:

Dim item as Object = Nothing 
For Each item in myObject 
...do something.. 
Next 

Now I would write it like this:

For Each item As Object In myObject 
    ...do something... 
Next 

I knew that C# can do this, but for some reason I never knew that VB.NET could also handle this syntax.

Add comment


(Will show your Gravatar icon)  

biuquote
  • Comment
  • Preview
Loading




Powered by BlogEngine.NET Theme by Mads Kristensen Hosted by 1and1 Hosting Sign in
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way. © 2008 Chris Blankenship

DSCODUC on Technorati  

Stop Spam Harvesters, Join Project Honey Pot   This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License  

Welcome to my blog

Welcome to my site

Villainy wears many masks,
none of which so dangerous as virtue…



LinkedIn   GeoURL

Recent Comments

Comment RSS

Wordle Gallery

Shelfari Book Library