Results 1 to 9 of 9

Thread: how to break for...next statement

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 2013
    Posts
    4

    how to break for...next statement

    helo guys have a good day..any way i have problem im making quiz project but im stuck for loop please any one can help me?
    example(i have 60 array form loop.. i i can't stop the loop if the user get 5 wrong or get 40 correct..

    here my sample code


    For i = 0 To intfForms - 1
    Set frmQuiz = Forms.Add("frmQuiz" & frmQuizArray(i))
    frm.Show vbModal
    Set frm = Nothing
    Next i

    i want to insert this code

    if quiz.markwrong = 5 then
    formfailed.show
    elseif quiz.mark check = 40 then
    formpassed.show
    else
    quiz.markWrong = quiz.markWrong
    quiz.markCheck = quiz.mark check
    End if


    thanks
    sorry for my bad English and ugly code im just a newbie

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: how to break for...next statement

    Welcome to the forums.

    I'm not completely sure what you are trying to accomplish, but if you need to get out of a For/Next loop use
    Code:
    Exit For

  3. #3
    PowerPoster Zvoni's Avatar
    Join Date
    Sep 2012
    Location
    To the moon and then left
    Posts
    4,419

    Re: how to break for...next statement

    I'm trying to wrap my mind around this one:

    Code:
    Set frmQuiz = Forms.Add("frmQuiz" & frmQuizArray(i))
            frm.Show vbModal
            Set frm = Nothing
    You set frmQuiz, but use frm in the next line.....
    Last edited by Zvoni; Tomorrow at 31:69 PM.
    ----------------------------------------------------------------------------------------

    One System to rule them all, One Code to find them,
    One IDE to bring them all, and to the Framework bind them,
    in the Land of Redmond, where the Windows lie
    ---------------------------------------------------------------------------------
    People call me crazy because i'm jumping out of perfectly fine airplanes.
    ---------------------------------------------------------------------------------
    Code is like a joke: If you have to explain it, it's bad

  4. #4

    Thread Starter
    New Member
    Join Date
    Nov 2013
    Posts
    4

    Re: how to break for...next statement

    Quote Originally Posted by Hack View Post
    Welcome to the forums.

    I'm not completely sure what you are trying to accomplish, but if you need to get out of a For/Next loop use
    Code:
    Exit For
    Thanks Hack.. a little bit i can move on.. let me explain you what i want to accomplish is a Quiz Project i decided to make 40 form..
    each form have a difference question. thanks for your forum i find out how to random it.. here is my problem im stuck to break the random loop form.. im trying to insert this..
    if the USER(person) hit 5 Wrong the the loop will stop and FormFail will appear /if the User(person) reach the 40 passing score formpassed will appear..


    Code:
     intNumberOfForms = 10
    
        frmQuizArray = Shuffle(intNumberOfForms - 1)
        
        For i = 0 To intfForms - 1
            Set frm = Forms.Add("frmQuiz" & frmArrQuizArray(i))
            If quiz.markWrong >= 5 Then
                 FormFail.Show
                 Exit For
             ElseIf quiz.markCheck >= 40 Then
                  FormPassed.Show
             End If
        Next i
    its working but some times debug(object unloaded)... did i mistaken to if..else statement.
    im realy trying to understand it but i cant figure out.. thanks again Hack and God bless you

  5. #5

    Thread Starter
    New Member
    Join Date
    Nov 2013
    Posts
    4

    Re: how to break for...next statement

    My bad

  6. #6
    PowerPoster Arnoutdv's Avatar
    Join Date
    Oct 2013
    Posts
    5,872

    Re: how to break for...next statement

    You have 40 forms for a quiz??

    What's the difference for the 40 questions in the quiz, besides the question and it's answers?

  7. #7
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: how to break for...next statement

    Use just one form for the quiz. This one form can contain 40 questions easily.

  8. #8
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,344

    Re: how to break for...next statement

    Quote Originally Posted by Hack View Post
    Use just one form for the quiz. This one form can contain 40 questions easily.
    Or mhadz could set it out like the wizards such as they only seem to use one form and each time you click "Previous" or "Next" the form is refreshed with the new information.
    when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    https://get.cryptobrowser.site/30/4111672

  9. #9
    Lively Member
    Join Date
    Oct 2013
    Posts
    124

    Re: how to break for...next statement

    mhadz, you're trying to take all the fun out of it, unless you are really stuck for time.

    One of the big thrills of school for me was that I never knew what I would get on tests. Partly because I spent my evenings drinking beer instead of studying.

    The tests were exciting because I didn't know whether I had passed or failed for days some times.

    Remember, the client's needs come first. Maybe your clients need a little thrill rather than an instant answer.

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