For Next Loop VB.NET

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • 17beach
    New Member
    • Sep 2006
    • 8

    For Next Loop VB.NET

    I am running a web application and processing some data within a loop under certain situation s I would like a button to be displayed and the user to run the code behind the button and then return to processing the loop I don’t want to exit for loop I just want to do some additional processing and continue until the end of the loop. The code below may be over simplified but the problem is still essentially the same. How can I stop the loop run some code and resume?
    Thanks any help would be aprreciated


    For x = 0 to 100
    Keep doing stuff
    -----------
    ------------

    ‘Here we had a condition that occurs more than once within the loop
    if (x= 13 or x =76 or x= 90 ) then
    ‘Allow the user to click button1 and run the code for
    ‘And then Resume Don’t just display the button and
    ‘And Fly past
    button1.visible = true

    End if


    Next
  • JKing
    Recognized Expert Top Contributor
    • Jun 2007
    • 1206

    #2
    Is it imperative that the user be required to click a button? Why not just have the code the button executes placed directly within the if statement? This way the loop will continue and the extra processing the button provides will be executed each time the if statement is entered.

    Comment

    • 17beach
      New Member
      • Sep 2006
      • 8

      #3
      Yes it is imperative that the user clicks button 1 becuase on the button1 click event the user is presented with some options for simplicity
      lets say click button 2 if you like this number or button 3 if you dont like this number.
      Any help appreciated Thanks

      Comment

      • JKing
        Recognized Expert Top Contributor
        • Jun 2007
        • 1206

        #4
        You could use a message box with yes/no buttons on it. This would halt code execution and achieve the same result as two buttons.

        Comment

        • Plater
          Recognized Expert Expert
          • Apr 2007
          • 7872

          #5
          Well as a web application, pretty much all of your button clicks will cause a postback and your page to reload, so I'm not sure how you want to keep your loop running.

          Comment

          • 17beach
            New Member
            • Sep 2006
            • 8

            #6
            Originally posted by JKing
            You could use a message box with yes/no buttons on it. This would halt code execution and achieve the same result as two buttons.
            Thanks but a java script alert would would not run code and if so not on the server

            Comment

            • Frinavale
              Recognized Expert Expert
              • Oct 2006
              • 9749

              #7
              Originally posted by Plater
              Well as a web application, pretty much all of your button clicks will cause a postback and your page to reload, so I'm not sure how you want to keep your loop running.
              Plater's right here,

              The way it works is:
              1) user makes request
              2) your code is processed
              3) the information is sent back to the user ...all processing stops

              There's no way to "pause" the code.

              Say the user clicks a button:
              -a number is generated by the server and is presented to the user.
              -the user is also presented with 2 buttons "do you like this number:" a yes button and a no button.

              If they click the yes button, then you do whatever you do.
              If they click the no button, then you generate another number.

              You could save the information that you were gathering while looping in session or something until they confirm or deny...but you cannot pause your code in a web application.


              -Frinny

              Comment

              • 17beach
                New Member
                • Sep 2006
                • 8

                #8
                Thanks to yourself and everyone else ... got your point. I will leave this idea and move on.

                Comment

                • JKing
                  Recognized Expert Top Contributor
                  • Jun 2007
                  • 1206

                  #9
                  Originally posted by 17beach
                  Thanks but a java script alert would would not run code and if so not on the server
                  I apologize, I seemed to have missed that you were making a web application.

                  Jking

                  Comment

                  Working...