Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6755757
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T13:26:27+00:00 2026-05-26T13:26:27+00:00

I have a for loop that goes to a site and posts to its

  • 0

I have a for loop that goes to a site and posts to its forms. For every item in the listbox I want it to wait for the user to fill out the data to the site, then move. The key point here is ‘wait’.

So my question is: is it possible to make a for loop to wait for user input?

This is the for loop I am working in order to load the data to the forms:

if (webBrowser1.DocumentText.Contains("Welcome"))
{   
    for (int i = 0; i < listBox4.Items.Count; i++ )
    {

        listBox4.SetSelected(i, true);
        listBox5.SetSelected(i, true);
        //coded to submit to form

        Application.DoEvents();
    }
}

This is the code to click submit on the site:

Application.DoEvents();
foreach (HtmlElement webpageelement in allelements)
{

     if (webpageelement.GetAttribute("value") == "Submit")
     {
         webpageelement.InvokeMember("click");
         Application.DoEvents();

     }

 }

I’ve also tried making a for loop without the code in it to make it go on. For ex: i++ and make an if statement to make it go on but that lagged my interface.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T13:26:28+00:00Added an answer on May 26, 2026 at 1:26 pm

    It is not a good solution to do a for or a while loop to wait for user input. Don’t do that. Your program will be constantly working while waiting for the condition to get it out of the loop. Instead, you should find a solution using events or else.

    If you don’t want to use the Form.ShowDialog() solution proposed in your question comments, you could come up with something like that:

    Have a global variable that holds the index of the listBox item we are working on:

    int currentItemIndex;
    

    Add a Click event on your Submit button. When the user clicks on Submit, it calls the method that will process the next listBox item:

    private void buttonSubmit_Click(Object sender, EventArgs e) {
        // Process next listBox item
        ProcessNextItem();
    }
    

    The method that processes the next listBox item:

    private void ProcessNextItem() {
        currentItemIndex += 1;
        if (currentItemIndex >= listBox.Items.Count) {
            // We have gone through all listBox items
    
            // Do nothing
        } else {
            // Fill predefined information to the website
            website.SomeField = listBox.Items[currentItemIndex].SomeField; // Whatever you do to fill predefined information
    }
    

    And call a method at the start (the user doesn’t click on Submit before the first listBox item is processed):

    private void Start() {
        currentItemIndex = -1;
        ProcessNextItem();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a loop that goes through all the news items we have on
I have this nested loop that goes 4 levels deep to find all the
I have a do/while loop that goes over database rows. Because it runs many
I have a while loop that goes through a table and I echo the
I have a simple foreach loop that goes through the productID's I have stored
I have a for loop that goes through each input with class=required , and
I have a simple jquery loop that goes through my form and sees if
I have a loop that goes something like this, where arrayfunction sets all array
I have a loop, that goes through some entries. In the loop I'm getting
I have a foreach loop that has try catch and finally. it goes through

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.