On Jun 19, 2006, at 3:31 PM, Chuck Pelto wrote:
On Jun 19, 2006, at 1:04 PM, Charles Yeomans wrote:
On Jun 19, 2006, at 2:49 PM, Chuck Pelto wrote:
Hi Maarten
On Jun 19, 2006, at 12:33 PM, Maarten de Vries wrote:
There probably is, but it seems a bit like overkill... I would
suggest you
either pass only the data required or the controls containing
the data. I
don't see why you'de have to cycle every control on the window.
If you don't
know the number of the controls/data you need to pass, make the
parameter an
array.
Actually, I think it's better to have a reusable module that
takes ANY window and extracts data from the various elements
where data is stored within than to build the same sort of
functionality into every window of every application.
Yeah...the machines have to do more work, but that beats the heck
out of ME doing more work in writing code.
The question remains, how do I access a control element, such as
an EditField with a Control Class object?
You cast the reference to the correct type.
For i as Integer = 0 to self.ControlCount - 1
If Control(i) IsA EditField then
...
ElseIf Control(i) IsA PopupMenu then
...
ElseIf ...
Else
End if
Next
But I don't see a good way to make your approach work in general.
For example, suppose you have a PopupMenu. How does one know
whether its values represent tables or fields? You can begin
writing subclasses of controls like SQLTablePopupMenu...
I've got a module method that extracts the data from things like
Popup Menus. I'll be passing such a control to that module to get a
return value for the value contained therein.
My current challenge is trying to get the data from a simple
EditField. I'll tackle the others as I get to them. And, where you
put the ellipsis is where I'm not figuring it out.
If Control(i) IsA EditField then
dim theText as String = EditField(Control(i)).Text
The bit EditField(Control(i)) is called "typecasting". You're
telling the compiler to treat the reference returned by Control(i) as
an EditField. If Control(i) is not an EditField, then the runtime
framework will raise an IllegalCastException, which is why one tests
first.
Charles Yeomans
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>