Are the windows similar in any way? If the layout of the forms is
identical, then I would strongly suggest having one form with the
spots where you put your questions, and then you create one and
insert your text on the fly. This would significantly reduce the
amount of memory your program needs.
If the numbering scheme you're using for the windows is a simple
serial number starting at zero, you could easily use a string array
for each piece of text. For example sQuestions(120) As String would
contain your questions, sExplanations(120) would contain your
explanations, sYesButtons(120) As String would contain the captions
for the buttons that equal to "Yes", sNoButtons(120) As String would
contain the captions for the buttons that equal to "No", and so on.
Then, for the order of your questions, you could use two arrays. The
first, sPrevQuestions(50) As String would contain a comma or dash
delimited list of the previous questions in order, and iNextQuestion
(50) As Integer would give the next question. The rows in these two
arrays would have to line up. For example, suppose you asked
questions 3, 2, 4 and 6 in that order. You could figure out what row
that's on in the first array... sPrevQuestions.Lookup
("3,2,4,6") .... and then pull that row from iNextQuestion().
Suppose the value in that cell is 9, so the next question to ask is
number nine.
To load all these arrays, I would suggest writing all the text in
text files, one for each array, and dragging the text files into your
project. Then, when the project is compiled, the text files will be
available to you at runtime in the form of strings. Use Split
(sourcetext, chr(13)) to convert a return delimited text file into an
array. If you are using Windows, I believe a return is actually chr
(13) + chr(10).
Again, I don't know exactly what your idea is, so I'm just throwing
an idea out there.
Now, as for actually answering your question... :) RB uses window
objects to reference windows, unlike VB, where you can use a string.
To tell you the truth, I don't know if you can access a window using
a string variable in RB. The suggestion Peter Truskier made about
using a dictionary is a good one. Because a dictionary uses
variants, any cell can have any one object, whether it's the same
type as the cells around it or not. Store your index into the key
and the window object into the value.
HTH,
Andrew Keller
On Aug 19, 2006, at 7: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...
Richard
_______________________________________________
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>