Debugging

Immediate Window

You can use the immediate window in VB to get the current values of variables and to run other code. To show it click View | Immediate. You can only use the immediate window when code execution is paused.


Immediate Window

Entering a ? and then the variable name or property will return its value, press RETURN to execute the query. The text below will return the path of your application, the text in italics is a possible result. Values in Italics are return results.

? App.Path
C:AppPathApp.EXE

The following example will return the value of the caption property:

? Label1.Caption
&Cancel

or perform calulations using variables or just numbers:

? Text1 * 10
198
? 100 / 1.92
52.0833333333333

You can also run one line or multiple statements. For example:

frmMain.Visible = False

To enter multiple lines of code, without it executing immediately press CTRL+Return

Below are a few examples

' This will return the number of Forms loaded into the memory
? Forms.Count
' This will return the name of Form(0) which is stored in the memory
? Forms(0).Name
' This will display a message box
Msgbox "hello"

You might also like...

Comments

About the author

James Crowley

James Crowley United Kingdom

James first started this website when learning Visual Basic back in 1999 whilst studying his GCSEs. The site grew steadily over the years while being run as a hobby - to a regular monthly audien...

Interested in writing for us? Find out more.

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“It is practically impossible to teach good programming style to students that have had prior exposure to BASIC. As potential programmers, they are mentally mutilated beyond hope of regeneration.” - E. W. Dijkstra