Need Help on a school project 
Author Message
 Need Help on a school project

This is the code that i used to set up an actual test. Now what i want to do
is if the person gets all three answer right a  form is shown, if not then
another form is shown.

Const instruction = "Type The Letter Of the Correct Response and " & _
                     "Click OK. Click Cancel To Skip This Question. " _
                     & vbCr & vbCr
Const choice = vbCr & vbCr & "A.Stop" & vbCr & _
               "B. Do Not Enter" & vbCr & "C. Slippery Road"
Dim intQuesnumber As Integer
Dim strQuestion As String
Dim strCorrectAnswer As String
Dim strResponse As String

frmTraffic.Hide
For intQuesnumber = 1 To 3
    Select Case intQuesnumber
        Case Is = 1
            Question = "1.Which Sign Has A Diamond Shape?" & choice
            strCorrectAnswer = "C"
        Case Is = 2
            Question = "2.Which Sign Has An Octagonal Shape?" & choice
            strCorrectAnswer = "A"
        Case Is = 3
            Question = "3.Which Sign Has A Round Shape?" & choice
            strCorrectAnswer = "B"
    End Select
strResponse = InputBox(instruction & Question, "Traffic Sign Shape Quiz")
Next



Tue, 05 Aug 2003 14:30:18 GMT  
 Need Help on a school project
see modifications to code below...

Const instruction = "Type The Letter Of the Correct Response and " & _
                     "Click OK. Click Cancel To Skip This Question. " _
                     & vbCr & vbCr
Const choice = vbCr & vbCr & "A.Stop" & vbCr & _
               "B. Do Not Enter" & vbCr & "C. Slippery Road"
Dim intQuesnumber As Integer
Dim strQuestion As String
Dim strCorrectAnswer As String
Dim strResponse As String
dim booPerfectScore as Boolean

frmTraffic.Hide
booPerfectScore = True            ' perfect score until they make a mistake
For intQuesnumber = 1 To 3
    Select Case intQuesnumber
        Case Is = 1
            Question = "1.Which Sign Has A Diamond Shape?" & choice
            strCorrectAnswer = "C"
        Case Is = 2
            Question = "2.Which Sign Has An Octagonal Shape?" & choice
            strCorrectAnswer = "A"
        Case Is = 3
            Question = "3.Which Sign Has A Round Shape?" & choice
            strCorrectAnswer = "B"
    End Select
    strResponse = InputBox(instruction & Question, "Traffic Sign Shape Quiz")

    ' (ucase forces answer to uppercase, trim gets rid of leading and trailing
junk whitespace)
    if ucase(trim(strResponse)) <> strCorrectAnswer then
        ' oops, got it wrong
        booPerfectScore = false
    endif
Next

if booPerfectScore then
  ' show the "all correct" form
else
  ' show the "oh dear" form
endif

********************************
Bear in mind that you will not know which question they got wrong or how many.
If you need to know this, create an array of booleans as well:
dim booCorrect(1 to maxQuestions) as boolean

then, for each question:
if *was correct answer* then
  booCorrect(question#) = true
else
  booCorrect(question#) = false
  booPerfectScore = false            '  if you leave this here, you can test
quickly to see if all were correct
                                                    ' saves going though the
entire array to get a quick answer.
endif

********************************

On a side note: If it is not outside of the scope of your project, don't forget
to use VB's visual components (after all, that's what it's best at).  Your
traffic question would possibly be better posed with radio buttons.  For
example:

        Is it illegal to run someone over?
            ( )  Yes
            (*) No

Anyway, best of luck, hope I have answered your questions.
Regards,
Paul.



Tue, 05 Aug 2003 12:06:19 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. school project need help now

2. Urgent Help needed for School Project!!

3. School project help in vb

4. Pleeeeaaase Help... School Project Due

5. School project help in vb

6. school project ... help

7. newbie - need help for timer proj for school

8. I need help for school

9. Help Needed Urgently (for school)

10. {Need Help Big Project Need Help}

11. project for school

12. SCHOOL PROJECT

 

 
Powered by phpBB® Forum Software