When using a SELECT CASE statement, is there a way to call it
back to itself? In other words, suppose I have the variable
SayThis, which contains a number of zero to 10,000. The way I
am watching my program work in the step by step, SELECT CASE is
checking every possibility, rather than avoiding some of them.
If SayThis = 9,999, then nearly every possibility is checked.
I.e.,
SELECT CASE SayThis
Case 0: Print “What do you want me to say?”
Case 1: print “Hello there, my name is Simon.”
Case 2: Print “What is your name?”
{{{and so on for 10,000 different statements}}}
I am wondering, could we speed that up? Will/should something
like this work?
SELECT CASE SayThis
Case 0 – 499
SELECT CASE SayThis
Case 0 – 99
Select case SayThis
Case 0: Print “What do you want me to say?”
Case 1: print “Hello there, my name is Simon.”
{ rest of statements }
End Select
Case 100 - 199
Select Case SayThis
Case 100:Print “What is the name of your pet?”
{ rest of statements }
End Select
{ rest of case options up to 499 }
End select
{rest of case options up to 10,000}
End Select
If it won’t work like this, can anyone suggest an alternative
perhaps? The computer this will eventually be used on was
assembled from the DOS days.
On my computer, the delay while it checks for the case is not
noticeable- but I wonder if it will be on a slower computer?
That is why I was hoping to find a way to cut down on the
options it has to check.
Thank you.
Robert
------------------
back to itself? In other words, suppose I have the variable
SayThis, which contains a number of zero to 10,000. The way I
am watching my program work in the step by step, SELECT CASE is
checking every possibility, rather than avoiding some of them.
If SayThis = 9,999, then nearly every possibility is checked.
I.e.,
SELECT CASE SayThis
Case 0: Print “What do you want me to say?”
Case 1: print “Hello there, my name is Simon.”
Case 2: Print “What is your name?”
{{{and so on for 10,000 different statements}}}
I am wondering, could we speed that up? Will/should something
like this work?
SELECT CASE SayThis
Case 0 – 499
SELECT CASE SayThis
Case 0 – 99
Select case SayThis
Case 0: Print “What do you want me to say?”
Case 1: print “Hello there, my name is Simon.”
{ rest of statements }
End Select
Case 100 - 199
Select Case SayThis
Case 100:Print “What is the name of your pet?”
{ rest of statements }
End Select
{ rest of case options up to 499 }
End select
{rest of case options up to 10,000}
End Select
If it won’t work like this, can anyone suggest an alternative
perhaps? The computer this will eventually be used on was
assembled from the DOS days.
On my computer, the delay while it checks for the case is not
noticeable- but I wonder if it will be on a slower computer?
That is why I was hoping to find a way to cut down on the
options it has to check.
Thank you.
Robert
------------------
Comment