On Aug 19, 2006, at 5:45 PM, Richard Hillsdon wrote:
Hi,
Ok, I'm new to RB but have to develop a package that is going
really well thanks to the ease of use of RB. I need one technical
issue solving that is driving me mad! As someone who has used VB
it was an easy one and an everyday task. I've found one article in
the archives, which sort of might do it, but actually more work and
more complex code than I want.
Here it is. The problem is simple. I have about 120 Windows in my
app that form a survey. The questions will be answered in a
different order each time, depending on the answers to previous
questions. So Window1 may be followed by Window3 etc. I also want
one subroutine that controls the display of all the Windows.
In theory this is easy. My code can create the name of the next
required form easily, such as "Window105". But how on earth can I
now load Window105 using a String as my reference? It's such a
simple requirement, but I cannot find a simple way to do it. In
Visual Basic (and I know this isn't the same language but just to
show what I need), I would simply have said forms(myNextForm) or
forms("Window105"). How can I do this in RB?
It's really holding me back from completing this project which I
need to do quick, and everything else is working fine. I could
also use an integer to determine the next Window to display if that
would help.
As I said, I've looked at one solution that kind of gets close to
the problem, but the amount of code required and sub-classing and
method add-ons would make it unworkable.
Any ideas? I've been searching all day for the answer to this
little problem...
You can't do it the same as in VB because RB is not VB.
The "name" of a class is JUST a name.
Your routine probably needs to look at the name requested and then do
a select case
select case formName
case "Window105"
return (new Window105)
case "Window106"
return (new Window106)
etc ....
end select
But since you can create the name, why not just actually create the
instance of the window ?
_______________________________________________
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>