Immediate Window in Visual Basic Editor

  • Thread starter Thread starter VanW
  • Start date Start date
V

VanW

I'm trying to practice simple Sub Procedures and Functions
using the Immediate Window. I noticed when I define the
Sub or Function in a Standard Module and declare it
Public, I can test it in the Immediate Window. However, if
I define it in a Class Module (let's say behind a form)
declare as Public or Private and try to run it from the
Immediate Window, I get an error message that says the Sub
or Function is not defined. Can you not use the Immediate
Window to test Sub's and Functions within Class Modules?
What am I doing wrong? I used the following simple
procedures. Also, it would not work in the Standard
Module also, unless I declared it Public.

Examples:

Public Function CubeVolume(Width, Length, Height) As
Integer
CubeVolume = Width * Length * Height

End Function

Public Sub Testing()
MsgBox "Hellow World from Vanessa"
End Sub

Used correct snytax in Immediate Windos also:
? CubeVolume(3,3,3) [hit enter]
Testing [hit enter]

Thanks for any help in advance!!!!!!!!!!
Van
 
If you have Form1 open in design view, you should be able to test your
procedure in the Immediate Window like this:
? Form_Form1.CubeVolume(3,3,3)

The "Form_" is how Access refers to the module of the form - see the Title
Bar of the module's window.

The proc will need to be public to test. You can make it Private after
testing.
 
Back
Top