KnowDotNet Visual Organizer

VS2005 (Whidbey) Restores VB6 Command Window Functionality Almost

Thank You Microsoft!

by Les Smith
Print this Article Discuss in Forums

Thankfully Microsoft has restored some of the VB6 Functionality to the Immediate (Command) Window in VS 2005 for VB.NET.  When I first tried Beta 1 of Visual Studio .NET (2002) back in 2000, I was greatly disappointed to find that a major feature of VB6, namely executing code in the command window of the Debugger at Design Time, was GONE!!!!  My first thought was they have broken VB!  This was such a powerful function for testing code at Design Time.

Thankfully, they have restored much of this functionality in the 2005 release of VB.NET,...but not all.

First, you can execute simple code in the Immediate Window such as the following:

?2+2
4

...and get the answer.  Not a big deal unless you want to compute something more complex than 2 + 2.

Next, you can execute a method (Shared) in an object from the window as shown below.  First, I will just create a method in a Form...

   Public Shared Sub test()
      MsgBox(
"Test")
  
End Sub

In the Immediate Window, place the following code and press Enter

form1.test

And the MsgBox will display your message.  So it is again possible to test small methods of your program from the Design Time Immediate Window.

I was disappointed though when I found that the following line, which worked in VB6,

    for i as integer =0 to 1:Msgbox(i.tostring):next i

gave me the following message...

Loop statements are not valid in the Immediate window.

I know it seems like I would complain if hung with a golden rope, but it would have been great if they had gone all the way when restoring the functionality.  But don't get me wrong, I am thankful for every bit of pampering that we VB programmers get.  Just kidding...I code in C# also


Writing Add-Ins for Visual Studio .NET
Writing Add-ins for Visual Studio .NET
by Les Smith
Apress Publishing