Reputation: 6557
I am trying to debug a form window written in VB6. It is to enter customer data so you can type in an address in the address field. You can also type in something like 90210 Main Street and on enter it will automatically parse the text and write the 90210 in the postal code field below and let Main Street be in the address field. It however can occasionally parse it wrong, which is what I am trying to fix.
The problem is that I can't figure out how exactly it is set up. If I type something into the TextBox address field and do a
?ADDRESS.text
In the immediate window, the it returns an empty string. There is also only a single function defined when I look in the dropdown list under the form. But when I set a breakpoint at it and click the textbox, then it doesn't break. It is the GotFocus() event:
Private Sub ADDRESS_GotFocus()
Call GCui.BM(ADDRESS)
End Sub
It's the same with the POSTALCODE textbox. It has DblClick, GotFocus and LostFocus event functions defined. But setting a break point in either one of them has no effect.
Is there any way of finding out where in the form the value Main Street or 90210 is stored? They are clearly visible in the ADDRESS textbox and the POSTALCODE textbox, but the immediate window returns an empty line when asking for their values.
Update 1:
It seems that someone has decided to completely rebuild the form with new controls. It probably happens in form.load. But I would still like to know if there is a way to search through variable values to find the string "Main Street" or "90210".
Update 2:
It turns out that there are two frames on top of each other. The top frame is hidden at startup and the bottom (almost identical frame with same labels and controls) are shown.
Upvotes: 0
Views: 397
Reputation: 1416
You can use the "Watch" feature. This will let you inspect all the properties of a form and all controls within the form and their values (look at the controls node).
You can also do this via code by looping over the form.controls collection.
Dim o As Object
For Each o In Me.Controls
If TypeOf o Is TextBox Then
Debug.Print o.Text
End If
Next
Upvotes: 2