How do I make it loop back to Case 0

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Jason Duong
    New Member
    • Mar 2012
    • 3

    How do I make it loop back to Case 0

    Public
    Class Form1
    Dim Evaluate As Integer = 0
    Dim answer As Integer = 0
    Private Sub form1_load (...) Handles MyBase.Load, btnTrue.Click, btnFalse.Click
    txtevaluate.Cle ar()
    Select Case Evaluate
    Case 0
    txtanswers.Text = "statement 1"
    Case 1
    txtanswers.Text = "statement 2"
    Case 2
    txtanswers.Text = "statement 3"
    Case 3
    txtanswers.Text = "statement 4"
    Case 4
    txtanswers.Text = "statement 5"
    Case 5
    txtanswers.Text = "statement 6"
    Case 6
    txtanswers.Text = "statement 7"
    Case 7
    txtresault.Text = CStr(answer) & " correct"
    Select Case answer
    Case 7
    txtevaluate.Tex t = "perfect"
    Case 5, 6
    txtevaluate.Tex t = "Excellent"
    Case Else
    txtevaluate.Tex t = "Retake the exam!"

    ( I am thinking right here I would do some kind of loop?) Or if then statement to go back?
    Like a MessageBox.Show ("You need to retake the exam!"), Thengo back to the TOP <---- this is the part I am stuck at. anyone who can help

    End Select
  • Guido Geurs
    Recognized Expert Contributor
    • Oct 2009
    • 767

    #2
    Is this VB.Net ?
    Please, if so, place this call in the right forum.

    Comment

    • Jason Duong
      New Member
      • Mar 2012
      • 3

      #3
      Originally posted by Guido Geurs
      Is this VB.Net ?
      Please, if so, place this call in the right forum.
      thanks for letting me know! I was wondering why i could not find my question. how do i move it?

      Comment

      • Rodney Roe
        New Member
        • Oct 2010
        • 61

        #4
        Why not put your case statements into it's own sub routine then you can call the sub and start that routine anytime you want. Also you need to "End Select" each case statement.

        Comment

        • rekedtechie
          New Member
          • Feb 2012
          • 51

          #5
          the comments above are the right way.. but if you dont want put your codes on a sub..
          you must try to add some handlings it looks like this..

          Code:
           
          myStartingHandler:
          'your case 0
          'your other case statement.
          'your conditions
          'if you need to go back in case 0
          'you need to type goto(your handler name)
          
          goto myStartingHandler
          
          'you can make a handler by adding colon at the end of your desired handler name
          
          'like error handlings..
          'i hope it helps.. =)

          Comment

          • Killer42
            Recognized Expert Expert
            • Oct 2006
            • 8429

            #6
            While I'm not as rabidly anti-GOTO as a lot of people, I think it's fair to say that in any "modern" programming language (I'm including VB6 in this), having to fall back on the the GOTO statement generally indicates bad structure.

            Comment

            • rekedtechie
              New Member
              • Feb 2012
              • 51

              #7
              and thats why i said, "the comments above are the right way." :)

              Comment

              Working...