Library tutorials & articles

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"

Comments

  1. 01 Jan 1999 at 00:00

    This thread is for discussions of Debugging.

Leave a comment

Sign in or Join us (it's free).

James Crowley 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 audience ...

Related discussion

Related podcasts

  • Christian Beauclair

    14 mai 2008 (�mission #0074) ::.Christian Beauclair: Stratégies de migration VB6 vers .NET Nous discutons avec Christian Beauclair des stratégies de migration VB6 vers .NET. Entre autres, nous discutons comment utiliser le "VB 6 Code Advisor" et le "Interop Forms Toolkit" pour ajouter la puiss...

Want to stay in touch with what's going on? Follow us on twitter!