Select Case Statement 
Author Message
 Select Case Statement

I do not know why this Select statement does not work.

result(item) holds the number of the row in a table
CorrectAns2(item2)  holds the contents of a field called "Correct Answer"
from the same row from above

I've named the radio group like this:

<td width="10%" align="center">&nbsp;</td>
<td width="7%" align="center">a)<input type="radio"
value="<%=objrs.fields("answer1")%>" name="<%= result(item)%>"></td>
 <td width="83%" align="left">&nbsp;<%=objrs.fields("answer1")%></td>
 </tr>

I throw the 2 response.write lines in to verify that I have the right
information, and I do
response.write result(item)
response.write CorrectAns2(item2)

So if I know that the question is number 10 (which is also the name of the
radio group),
and the answer is Christmas,

And the user presses Christmas as his choice, why doesn't this code work?

Select Case "request.Form(result(item))"
  Case "CorrectAns2(item2)"
    TotalCorrect = TotalCorrect + 1
  End Select

Terry



Thu, 05 May 2005 10:35:58 GMT  
 Select Case Statement

"> >

Quote:
> > Select Case "request.Form(result(item))"
> >   Case "CorrectAns2(item2)"
> >     TotalCorrect = TotalCorrect + 1
> >   End Select

> Get rid of the enclosing quotes and it might ;-)...  Your literally
> comparing 2 string literals.

Yes, you are right as usual.  Since I used this same type of statement
earlier, but with no variables,
I thought I could do it again only substituting variables (arrays) for the
choices.  I've got a lot to learn.

Thanks



Thu, 05 May 2005 12:41:26 GMT  
 Select Case Statement

Quote:
> And the user presses Christmas as his choice, why doesn't this code
> work?

> Select Case "request.Form(result(item))"
>   Case "CorrectAns2(item2)"
>     TotalCorrect = TotalCorrect + 1
>   End Select

Get rid of the enclosing quotes and it might ;-)...  Your literally
comparing 2 string literals.

--
Michael Harris
Microsoft.MVP.Scripting
Seattle WA US



Thu, 05 May 2005 11:56:18 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Select Case Statement Help

2. Select Case Statement

3. Criteria for select case statements

4. Embedded or nested Select Case statements

5. Using a wildcard string comparison in a select case statement

6. Select Case statement is driving me mad!

7. Can you nest Select Case statements?

8. If...Then...Else or Select Case Statement

9. select case statement

10. Select Case statement in VBScript

11. Select Case Statement

12. Select Case Statement

 

 
Powered by phpBB® Forum Software