Results 1 to 3 of 3

Thread: simple tester

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2000
    Location
    ISTANBUL/TURKEY
    Posts
    11

    Unhappy

    I want know how does simple tester. I m doing a test(questinos/answers)program now. How can I do?
    Bu forumdaki en cahil kiþi

  2. #2
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    there are plenty of ways..here is one.
    Code:
    'little question and answer
    'list1 and list2 listboxes
    'label 1
    
    Option Explicit
    
    Public sAnswer As String
    Public sCorrect As String
    
    
    Private Sub Form_Activate()
    
    'adjust text properties in label
    Label1.FontBold = True
    Label1.ForeColor = vbRed
    Label1.FontSize = 10
    Label1.Caption = ""
    
    'load the questions
    
    List1.AddItem "1 + 1 = "
    List1.AddItem "2 + 2 = "
    List1.AddItem "3 + 3 = "
    
    End Sub
    
    Private Sub List1_Click()
    
    'on click load the proposed answers
    
        If List1.ListIndex = 0 Then sAnswer = "1"
        If List1.ListIndex = 1 Then sAnswer = "2"
        If List1.ListIndex = 2 Then sAnswer = "3"
    
    'clear label1
    
        Label1.Caption = ""
    'build the case
    
    Select Case sAnswer
    
    Case "1"
        List2.Clear
        List2.AddItem "1"
        List2.AddItem "4"
        List2.AddItem "2"
        List2.AddItem "None of the above"
    
    Case "2"
        List2.Clear
        List2.AddItem "2"
        List2.AddItem "3"
        List2.AddItem "4"
        List2.AddItem "None of the above"
    Case "3"
        List2.Clear
        List2.AddItem "3"
        List2.AddItem "8"
        List2.AddItem "12"
        List2.AddItem "None of the above"
    
    End Select
    
    
    End Sub
    
    Private Sub List2_Click()
    
    'set the default to incorrect answer
    
        sCorrect = 4
        
    'if a correct answer for each question give appropriate case value
    
    If List1.ListIndex = 0 And List2.ListIndex = 2 Then sCorrect = 1
    If List1.ListIndex = 1 And List2.ListIndex = 2 Then sCorrect = 2
    If List1.ListIndex = 2 And List2.ListIndex = 3 Then sCorrect = 3
    
    'build the case
    
    Select Case sCorrect
    
        Case "1"
            Label1.Caption = "Correct Answer { 2 }"
            List2.Clear
            
        Case "2"
            Label1.Caption = "Correct Answer { 4 }"
            List2.Clear
            
        Case "3"
            Label1.Caption = "Correct Answer { None of the above! }"
            List2.Clear
            
        Case "4"
            MsgBox "Sorry, try again!"
            Label1.Caption = ""
    End Select
    
    
    End Sub
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  3. #3
    Guest
    Use an InputBox.

    Here is a sample quiz I made. Add the following to a Form with a CommandButton.
    Code:
    Private Sub Command1_Click()
        
        Dim Score As Integer
        
        Retval = InputBox("What planet do we live on?")
            If UCase(Retval) = "EARTH" Then Score = Score + 1
            
        Retval = InputBox("Who is the owner of Microsoft")
            If UCase(Retval) = "BILL GATES" Then Score = Score + 1
            
        Retval = InputBox("Who invented the telephone")
            If UCase(Retval) = "GRAHAM BELL" Then Score = Score + 1
            
        Retval = InputBox("Who had the highest PPG in the NBA")
            If UCase(Retval) = "MICHAEL JORDON" Then Score = Score + 1
            
        
        Select Case Score
            Case 0
                MsgBox "F-  Failed"
            Case 1
                MsgBox "D:  Poor"
            Case 2
                MsgBox "C:  Good try"
            Case 3
                MsgBox "B:  Excellent"
            Case 4
                MsgBox "A+  Outstanding"
        End Select
        
    End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width