What is the Immediates window used for? It always pops up when i run the program. Whats it do?
Printable View
What is the Immediates window used for? It always pops up when i run the program. Whats it do?
While you are debugging your program (eg: you have reached a breakpoint or pressed the "pause" icon) you can run code, such as:
..or:Code:Print x + 3
Code:form1.show
you can use it to inspect the value of things... execute simple code... and even use it to change the value of variables...
-tg
So i can type things into it? And have it do things not in the code for the project?
More or less, yes. It does allow you to change public variable values and values local to the routine that the code stopped in. You can call public functions and private functions within the module that the code stopped in.
You can also use it within your code to see values. Example.
Code:Dim X As Long, lSum As Long
For X = 1 to 10
lSum = lSum + Int(Rnd * 1000)
Debug.Print lSum
Next
' open immediate window (Ctrl+G) and see the results
In its simplest form it is a debugging tool (and an invaluable debugging tool) that you should become intimate with.
http://msdn.microsoft.com/en-us/libr...ffice.10).aspx
oh. ok. thank you all so much for the fast replys!
To save a few keystrokes you don't need to type
Print MyVar
to see the value of MyVar. You can just do
?MyVar
Besides printing and changing your variables you can also temporarily change the location and/or size of controls and/or your form. This can be useful if say you are designing a form and you want to move some control a little bit but you don't know exactly how much. In the Immediate Window you can type MyControl.Left = 1234 or MyControl.Left = 1245, etc until you have it exactly right, and once you have the value you can change MyControl's Left property in the IDE. That's a lot faster than doing it over and over in the IDE directly.
BTW some uses of the Immediate Window are discussed in my VB6 Debug Tutorial.
oh. Okay. I get it now. thanks!