Dumb question on debugging (1 Viewer)

Z34Lee

Registered User.
Local time
Today, 07:38
Joined
Dec 8, 2006
Messages
22
I've searched and couldn't find an answer. This is going to sound stupid, but why can't I step-into and debug code unless it is in a Module?
 

KeithG

AWF VIP
Local time
Today, 04:38
Joined
Mar 23, 2006
Messages
2,592
I don't understand your question. Where do you write code besides a module?
 

Z34Lee

Registered User.
Local time
Today, 07:38
Joined
Dec 8, 2006
Messages
22
KeithG said:
I don't understand your question. Where do you write code besides a module?

When I'm working on code in within forms.
 

Jimmy the Hand

New member
Local time
Today, 13:38
Joined
Oct 12, 2006
Messages
7
Event procedures don't start with F5 or F8. They are called on by the corresponding events. However, you can put breakpoints into the event procedures, too. Breakpoints will stop code execution, and then you can use F8 to step by step debugging. But you still have to click on the button, or change the textbox, or whatever it is that fires that particular event procedure.
 

Z34Lee

Registered User.
Local time
Today, 07:38
Joined
Dec 8, 2006
Messages
22
Thanks - I was hoping there was a way to run the code without actually triggering the event but I guess that is not possible.
 

Jimmy the Hand

New member
Local time
Today, 13:38
Joined
Oct 12, 2006
Messages
7
Let's assume this is the event procedure of Button1

Code:
Private Sub Button1_Click()
   'code line 1
   'code line 2
   'code line 3
End Sub

You can break it into two like this
Code:
'This goes to a standard module
Sub Button1_Click_Core()
   'code line 1
   'code line 2
   'code line 3
End sub

'This stays on form's module
Private Sub Button1_Click()
   Button1_Click_Core
End Sub

If you put the core code of the event procedure into a standard code module, you can test/debug it independently of the event. Of course this path is not always passable, but sometimes it is.
 

Users who are viewing this thread

Top Bottom