express VB.NET my.fav

12 Aug

Scripting, programming, developing… unfortunately these three things tend to blur together in practice but they are very distinct.  Scripting is the most basic form of automation and you should not confuse someone who can write a script with a programmer.  Programmers have a leg up and the advantage of an environment to compile their code and perform complicated tasks with fewer lines.  Developers take advantage of the hard work of others and make something spectacular(maybe).

Deciding what to code with…

$$$ – VB.NET/SQL express editions are free.  You can write an amazing piece of software with these items.  Where the costs come in is when you outgrow the express editions and need to purchase windows server or meet one of these criteria:

4gb+ database
windows service templates
easier implementation of SDKs

I have even recently heard about a linux tool called MONO where you can run your .NET code without windows.  It may be difficult to support but the point is you can do this for free.

So take a break and go download the express editions and take control of your computer(s).

When you make a new Visual Basic Express project you have a handful of options.  I have experience with console applications and windows form applications (a.k.a. GUI).  In the matter of about 10 seconds you can load the IDE pick new console application press these keys“world.txt”, “hello!”) [f5]

and there you have it your hello world app.  Have you ever heard this quote, “Notepad is the best for coding.”  If you have done the example above you’ll now be able to look down you nose at the scripter who quoted that line.  You can do this because you know that the development environment made you more efficient by setting up your module, directories and giving you IntelliSense to finish each class in the example which is really:

Module Module1
    Sub Main()"world.txt", "hello!")
    End Sub
End Module

[f5] (to compile and run)

With a little practice you can actually do this .NET example in less than 10 seconds.  The Microsoft IDE is much faster than its IBM or open source counterparts.

VB.NET is not much different than C#.  Many of the benefits of VB carry over to C#. They have the same IntelliSense into the framework.  In fact they are so similar there are many free webapps that will convert the code back and forth automagically. I like VB.NET better because the syntax just makes sense.  It is a little more verbose which makes it more human readable. With the power of auto-complete you end up hitting closer to the same number of keystrokes.

In the latest 2010 version if you highlight a variable or other piece of text all other matches will be highlighted showing you if you change that value you will be changing these other pieces of code.  The [f5] part of the example actually compiles you .exe and runs it in debug mode.  Move the cursor down to the write line and press [f9] to set a break point.  The next time you compile in debug mode the program will stop at that line and you can examine your variable values.  At this point you can view “debug windows” such as the call stack or watch windows.

This debug mode is the only way to write code.  Stepping line by line using f10 and stepping into any subroutines and functions using f11 will help you remove errors, hence the name “debug”. If you are not using debug mode you are a scripter and nothing more.

Good code handles errors that may arise.  The last resort to handling errors you did not expect is the try/catch.  In the IDE typing “try” and pressing enter will give you the basic syntax.  If your statements inside the try work the statements inside the catch are never processed. All good programs have some form of exception logging such as:

System.IO.File.AppendAllText("error.log", ex.ToString system.environment.newline)

Especially with silent running console apps you need this error handling.  Let the user know the program failed and then give the developer meaningful information to help resolve the issue.

The best way to describe why I like vb the best is to post some code examples.  Once I figure out a way to easily maintain the syntax highlighting and insert some screenshots I will have a better VB.NET post for you.

1 Comment

Posted by on August 12, 2010 in .NET


One response to “express VB.NET my.fav

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: