Results 1 to 2 of 2

Thread: how to move to the next question using sequential file

  1. #1

    Thread Starter
    Member
    Join Date
    Apr 2000
    Location
    Birmingham UK
    Posts
    50

    Question

    Hi i need some help as my logics have just die on me for a week ok let get down to the point I am designing a small program like a quiz the problem comes how do i move onto the next line in sequential file ok here is my code

    Open (App.Path & "\txtquestion.txt") For Input As Myfile
    ' so it open the file fine no probs
    Input #Myfile, QuestionA

    Input #Myfile, answerA
    Input #Myfile, opA
    Input #Myfile, answerB
    Input #Myfile, opB
    Input #Myfile, answerC
    Input #Myfile, opC
    Input #Myfile, answerD
    Input #Myfile, o

    loads all of the above fine no probs


    this is where the problem starts so please help me as i said my head is a bit dead and has been dead for a week you know the feeling sometime .

    Private Sub lblnext_Click()


    Do While Not (EOF(1))

    Line Input #1, QuestionA
    txtquestion.Text = Trim$(QuestionA)
    Line Input #1, opA
    txtopA.Text = Trim$(opA)

    Line Input #1, opB
    txtopB.Text = Trim$(opB)

    Line Input #1, opC
    txtOpC.Text = Trim$(opC)

    Line Input #1, opD
    txtOpD.Text = Trim$(opD)

    this is where i can't sort my self out it goes throught the loop ok but just how just how do i stop the loop so when the user is ready to move onto the next question he/she just clicks on the command button u know next for next question ...

    please email me on [email protected] please help me
    i am frusrated as i know the answer but can't wirte it down u know what i mean.....


    Loop












    Waheed Rafiq (ICT Technician):
    Network +

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

    <?>

    <?>

    If you'd like to rethink it and use listboxes here is
    a small sample of how it works with those.
    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

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