September 2, 2014
Hot Topics:
RSS RSS feed Download our iPhone app

VB.NET Uncovered: Big Changes

  • October 20, 2002
  • By Karl Moore
  • Send Email »
  • More Articles »

There's no doubt about it - VB.NET brings with it big coding changes.

And every time I pen an article detailing the differences, I receive hate mail and continual ICQ harassment. In fact, I'm still trying to think of a witty response to: "I mean, why the HELL did YOU remove the Shape control?"

So I'll admit from the start that not everyone will agree with this shift. It's a big change and, hey, nobody likes change. But once you really start to understand why these things are here and how to use themproperly, suddenly it all begins to make sense. Sorta.

Anyway, let's try to figure it out - by venturing off into the code window:

  • Create a new Windows Application
  • Slap a new Button onto Form1
  • Right-click on Form1
  • Select 'View Code'

Welcome to the Code Window!


Blow Up!

Now, you're probably already scratching that head. And if you aren't, you should be. I was darn confused by this point already.

Where did all that code come from? And the strange answer is that you did it.

Nope, you weren't intermittently possessed by Bill Gates, made to tap out this groovy VB.NET project with related form code, knocked on your head then forced to forgot it all by the use of hypnotic suggestion and rather large magnets. Though I guess it is remotely possible.

But no - this is all created when you add a new Windows Form. Still, what does it all do?

Well, it looks incredibly, incredibly weird. However at its core, this code simply describes your form.

Remember I said that all files in VB.NET have a .vb extension? Well, VB.NET knows it's a form because all this code behind the scenes tells it so. It describes everything from the form name through to itsdimensions, through to the controls you'll find upon it.

Top Tip: If you look through the code behind this form, you'll notice that Form1 is actually a class. From VB4 onwards, we've been able to treat forms as classes - but in reality, they neverreally were. With VB.NET, they are - and come with all the usual stuff you'll find in VB.NET classes, including Constructors and the Dispose method. More on this later.

So that's what all the extra code is about. Boring stuff, really... just ignore it for the mo. Now, let's look at creating our own code...

Top Tip: You can expand or hide chunks of code using the 'plus' and 'minus signs to the left of your code window. You can also define your own 'hideable' regions using the #Region statement. Check out the help for more information.





Page 4 of 7



Comment and Contribute

 


(Maximum characters: 1200). You have characters left.

 

 


Sitemap | Contact Us

Rocket Fuel