Beginner's Visual Basic Question

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I just started learning Visual Basic for Access 2003. I can use the
userforms and they give me back results when I try a message box. I'm
reading an older instruction lesson book from a few years ago that gives
instruction for "Visual Basic 6.0". When I do the following Sub in the
UserForm "View Code", things work brilliantly:

Public Sub UserForm_Click()
MsgBox "Hello World"
End Sub

However, when I try to the "Debug.Print", the lesson says I should get a
visible "2" on the form after clicking on it. But nothing is happening.
Can anyone put me in the right direction?


Private Sub UserForm_Click()
Debug.Print 4 / 2
End Sub
 
Debug.Print prints to the Immediate Window. When you're in the VB Editor
looking at your code, press Ctl-G or choose "Immediate Window" from the
View Menu and you should see what the Debug.Print printed.
 
Hi:

The Debug statement prints to an Immediate window in the Visual Basic Editor
(VBE). After the code stops at breakpoint, press F8 to execute the line.
Then press CTRL+G to view the Immediate window and you should see the result
of Debug.Print in this window.

Regards,

Naresh Nichani
Microsoft Access MVP
 
Visual Basic 6.0 userforms and Access forms are different beasts
although they have many features in common and usually look the same.
The differences between VB6 controls such as textboxes and comboboxes
and their Access equivalents are even greater.

As a result, even though Visual Basic 6 and the Visual Basic for
Applications 6 used in Office 2003 are basically the same language, with
the same syntax and core, you'll continually hit snags if you use a VB6
reference when working with Access objects.
 
Back
Top