I’m stuck with something that is probably simple to do…
I have created a method that read all the controls of the window in order to add data to my database. This is working great so far. Now I have more windows so it makes sense to make a global method to do this instead of having the same method in each window.
But this is where the but is… I can’t figure out how to have this global method to read the controls of the specific window that called the method. (For example, "window1.textfield.Text ", though window1 need to be pointing to any window that call the method) I can imagine that I need to pass the window information as a parameter, but I don’t see how to do that… any input on this please?
Thanks Dave for your answer. I think I don’t understand something about ‘defined as Function’. How is that different that simply adding a Method with a parameter?
Alright, so I tried that and it works fine with the window property (like win.Title) but I got it wrong with the controls on that windows.
When looking at win.TextField1.Text it gives me the following error "Type “Window” has no member named “TextField1”. Any idea?
I think you need to access controls thru the “controls array”… I don’t recall the exact syntax, but its not straight forward…
Dim c As Control
For i As Integer = 0 To Self.ControlCount-1
c = window.Control(i)
If c IsA TextField Then
if c.name="TextField1" then
..... do something
end
End If
Next
“control” is a property of the window… and textfield1 is a member of control… so its one level down from the actual window itself