Click here to Skip to main content
15,311,151 members
Articles / Programming Languages / Visual Basic
Posted 20 Jul 2004


15 bookmarked

A First Look to VB.NET Express

Rate me:
Please Sign up or sign in to vote.
3.03/5 (11 votes)
25 Nov 20048 min read
Exploring what VB.NET Express product from Whidbey VS.NET 2005 can offer.


I will try to explain to you what VB.NET Express 2005 Beta can offer in this article. Hopefully, you will learn something from it.

I first created a new Windows form project. It is very easy to do so. File->New Project and Choose Windows Application. VB.NET Express asks you project name but do not ask where it should be saved. Interesting thing is that VB.NET Express allows me to run my solution without saving it first. VS 2003 forces you to save your application first, as I remember. I think it uses temporary folder for this. Later when you save your project it asks you where to save it. You can change project name here too.

As in the VS.NET 2003, this action creates a Form1.vb. You can see solution explorer when you first create project below.

Image 1

As my habit, I change this Form1.vb to something more meaningful. Since I decided to try "My" functionality and I knew from blog postings that My functionality makes file tasks easier, I decided to rename this to frmWriteTextToFile.vb. Then as my habit I looked at the code to rename class declarations too.

Surprise! Surprise!

When you rename your class file, automatically your class is renamed in the text file. I created a new class to test this functionality. I called this class from windows form object and renamed class. What I saw is that, all the caller's are renamed too. What can I say, very good. I was always annoyed to about deciding proper names for my classes since I knew that renaming them will be problematic later. If your source control will be able to deal with renamed files ( source safe 6.0d cannot ), it is very nice to have such functionality.

I added this simple method and wrote code as below:

Public Shared Sub WriteToFile(ByVal fileToBeWritten As String, _
                                ByVal TextToBeWritten As String)
   If (My.Computer.FileSystem.FileExists(fileToBeWritten)) Then
      My.Computer.FileSystem.WriteAllText(fileToBeWritten, _
                                            TextToBeWritten, True)
      My.Computer.FileSystem.WriteAllText(fileToBeWritten, _
                                            TextToBeWritten, False)
   End If
End Sub

This code writes a string to text file. If file exists, it simply appends your string to end of file otherwise it creates a new file and write your string to that file. Writing to a file is as simple as this. Compare this to C# version or 1.1 VB.NET version.

After writing this class, I added one TextBox for filetobeWritten and one multiline TextBox for textToBeWritten and one button for actually calling WriteToFile method. When I was changing names for this object, I saw one more improvement in the IDE. VB.NET now have events tab as C#.NET 2003. If you are coming from VB6 to VB.NET, you may not need them. But I first learned C#, then I started using VB.NET. As I am using both VB and C#, I look for such things in IDE. In my opinion apart from language changes, IDE should support same things in the editor. References are one more thing which C#.NET 2003 have but VB.NET 2003 does not. It is better implemented too.

Image 2

You can see references in Find Symbol Results window.

Image 3

In C#, you can go to caller but here you see all callers.

In the same menu, Insert Comment is same as C# comment ability or VBCommenter. It works with pressing three times ( ' ),''' also with this menu. Rename is the Refactoring Rename. Rename this method to something else and all of the callers will be changed as I have mentioned before. What is good is that, when you rename in the caller code, it works too. I read that rename refactoring is implemented and they are working in other refactorings in one of the Visual Basic TechED presentations. Rename certainly works. I hope to see other refactoring in Whidbey VB.NET 2005.

They have made bookmark usable thing also. In VS.NET 2003 bookmarks worked in only in one file. Here they works across files. Very Good.

Image 4

There are Next Bookmark in Document and Previous Bookmark in Document. But I think they will not be used much unless you have very large files with 1K or more lines. And with that files you should think about splitting it to more smaller files.

When I tried to call my sample method from Windows Form, I saw another new thing. VB.NET Express have a very good intelligent trick as you can see in the image below.

Image 5

Common tab shows only methods I have written. All Tabs shows methods, my class inherit from object.

In the Solution Explorer, come to MyProject and open it. You see better designed menu for your project.

Image 6

Choose Assembly Information.

Image 7

In this dialog box, you will be better able to change your Assembly Information. All of these things are only changeable via file in VS 2003. Choose View Code here. You see the below code in MyProject\MyEvents.vb file.

Namespace My
   Partial Friend Class MyApplication
      'Use the editor window dropdowns in the Application pane of 
      ' the Project Designer to handle MyApplication Events
      'Startup: Raised when the application starts, before the 
      'startup form is created.
      'Shutdown: Raised after all application forms are closed. 
      'This event is not raised if the application 

      'is terminating abnormally.
      'UnhandledException: Raised if the application encounters an 
      'unhandled exception.
      'StartupNextInstance: Raised when launching a single-instance 
      'application and the application is already active. 
      'NetworkAvailabilityChanged: Raised when the network connection is 
      'connected or disconnected.
   End Class
End Namespace

You can add application wide events here using normal event adding.

Image 8

Private Sub MyApplication_Startup(ByVal sender As Object, _
       ByVal e As System.Windows.Forms.StartupEventArgs) Handles Me.Startup
    MessageBox.Show("Hello World")
End Sub

A simple code, but it demonstrates a feature only.

After this, VB.NET Express demonstrated to me that it is Beta Product.

Image 9

Well, I am taking my word back about renaming. It seems that even though I renamed my Form1 as frmWriteTextToFile, some references exists in VB.NET Express to Form1.This exception is generated since I have tried to set my splash screen to frmWriteTextToFile. I am sure that these problems will be solved in normal product. I solved this problem in this way. In the solution explorer Show All Files.

Image 10

Open MyApplication.myapp. This is XML file. MyApplication.vb is auto generated VB file from this XML file. I first tried to change this line in MyApplication.vb.

<System.Diagnostics.DebuggerStepThrough()> _
Protected Overrides Sub OnCreateMainForm()
    Me.MainForm = My.Forms.Form1
End Sub

But since this file is autogenerated, it kept coming back when you change the line

<MainForm>VB.Net ExpressArticle.VB.Net 
in the MyApplication.myapp. Annoying Form1 errors will go away. If you have two forms and want to change which one of them starts first. This is the way to that too.

When you set show all files, you will see that for every windows form object you have three classes. For example for frmWriteTextToFile.vb, you also have frmWriteTextToFile.Designer.vb and frmWriteTextToFile.resx. Open the frmWriteTextToFile.Designer.vb you will see this declaration in class file.

Public Partial Class frmPerson
Inherits System.Windows.Forms.Form 

This file is partial class. In Whidbey and VB.NET Express, you can have a class which is split to more than one file. VB.NET Express stores automatically generated code in this partial file instead of

#region "Visual Studio Generated Code"-#endregion

Again in the My Project menu, there is Compiler tab. In this tab you can change Option Strict Option to ON/OFF/Custom.

Image 11

It is good to be able to change some of Option Strict Options. I am fan of option strict. But sometimes I had to close option strict because of legacy code. Correcting hundreds of errors in working code seems excessive. This way I will be able to reduce error area a bit at least.

A little addition.

Image 12

These additions are self explaining but very convenient to have in my opinion.

Second Click in the editor in a code line.

Image 13

Choose Insert Snippet.

Image 14

Choose Visual Basic Language.

Image 15

Choose Initialize an Array. This Code appears.

' Declare and initialize a one-dimensional array.
Dim oneDimArray() As Char = {"X"c, "Y"c, "Z"c}
' Declare and initialize a two-dimensional array.
Dim twoDimArray(,) As Double = {{5.8, 6.6}, {7.4, 8.2}}
'' Declare and initialize a jagged array.
Dim jaggedArray()() As Integer = {New Integer() {1, 2}, New Integer() {3, 4}}

Interesting thing about snippets is that, selections vary with where you choose to insert them. What I mean is that, Code snippets which are shown in context menu changes according to where you are. When you are inside sub or function, different snippets appear than when you are inside the class body. These snippets are very good to have. Most of the time, I forgot implementation of something and I had to search help for something trivial. These will be a very good productivity enhancers. I will give you a link for how to add code snippets in the end of article

In the code snippets I have found an example, which I think is a generic sample ( I know C# generics and C++ templates only at this time. I will remedy this situation) I modified it to some degree.

Public Class GenTry(Of entryType)
    Protected aList As ArrayList = New ArrayList(1)
    Public Sub Add(ByVal e As entryType)
    End Sub
    Public Function GetF() As entryType
        Return CType(aList.Item(0), entryType)
    End Function
End Class

Client function.

 Private Sub Button1_Click(ByVal sender As System.Object, _
         ByVal e As System.EventArgs) Handles Button1.Clic
    Dim strA As GenTry(Of String) = New GenTry(Of String)
    Dim IntB As GenTry(Of Integer) = New GenTry(Of Integer)
End Sub

As you can see I can add string and integers to the same collection code. And compiler complains if I try to add things other than Integer to IntB and string to strA.

Image 16

Image 17

Edit and Continue works in VB.NET Express too. Though some quirks exists.

Image 18

Things I missed.

  1. There is no Format Text Method in the Text menu. I use it a lot.
  2. Help is not very good right now. I have not installed MSDN Help which comes with Express as I am writing this since it was broken in my flash disk. I wanted to explore VB generics but I have not found any single code example in the VB Help. I hope that when I install help.
  3. Even though SQLExpress is installed in my PC, I was not able to connect to it. I think this is because I have both SQL Server 2000 and SQLExpress.

Of course, I was not able to explore all of what VB.NET Express can offer. But from what I have seen, it is very good for a FREE tool. Microsoft announced that Express products will be free to use.



This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Atilla Ozgur
Turkey Turkey
I started programming in 1991 with Amiga 68000 Assembler. I am a web and database developer proficient in different languages and databases

Comments and Discussions express with .NET framework 1.1 Pin
Anonymous4-Dec-04 12:06
MemberAnonymous4-Dec-04 12:06 
GeneralRe: express with .NET framework 1.1 Pin
eman198630-Sep-06 4:26
professionaleman198630-Sep-06 4:26 
GeneralWrong spelling of product name Pin
Michael Freidgeim25-Nov-04 11:34
MemberMichael Freidgeim25-Nov-04 11:34 
GeneralRe: Wrong spelling of product name Pin
Atilla Ozgur25-Nov-04 22:55
MemberAtilla Ozgur25-Nov-04 22:55 
GeneralSide by Side Install Pin
Muffadal23-Jul-04 20:52
MemberMuffadal23-Jul-04 20:52 
GeneralRe: Side by Side Install Pin
mcarbenay23-Jul-04 21:40
Membermcarbenay23-Jul-04 21:40 
GeneralRe: Side by Side Install Pin
Atilla Ozgur24-Jul-04 1:56
MemberAtilla Ozgur24-Jul-04 1:56 
GeneralRe: Side by Side Install Pin
WillemM23-Aug-04 6:05
MemberWillemM23-Aug-04 6:05 
GeneralStill no pictures Pin
jconwell22-Jul-04 9:55
Memberjconwell22-Jul-04 9:55 
GeneralRe: Still no pictures Pin
Atilla Ozgur22-Jul-04 22:02
MemberAtilla Ozgur22-Jul-04 22:02 
GeneralRe: Still no pictures Pin
Laubi26-Nov-04 0:53
MemberLaubi26-Nov-04 0:53 
GeneralRe: Still no pictures Pin
Atilla Ozgur26-Nov-04 21:15
MemberAtilla Ozgur26-Nov-04 21:15 
GeneralLooks interesting - but no pictures Pin
Jabes21-Jul-04 1:31
MemberJabes21-Jul-04 1:31 
GeneralRe: Looks interesting - but no pictures Pin
Atilla Ozgur21-Jul-04 2:07
MemberAtilla Ozgur21-Jul-04 2:07 
GeneralFix the Images Pin
mohammed barqawi21-Jul-04 0:19
Membermohammed barqawi21-Jul-04 0:19 
GeneralRe: Fix the Images Pin
Atilla Ozgur21-Jul-04 1:49
MemberAtilla Ozgur21-Jul-04 1:49 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.