Results 1 to 3 of 3

Thread: Make Visual Basic Wait for User input

  1. #1

    Thread Starter
    Member
    Join Date
    Mar 2011
    Posts
    55

    Make Visual Basic Wait for User input

    Hey everyone,

    I am trying to figure out how to code a function that causes a function to pause until the user either changes a radiobutton or hits the reset button or that will restart the function if one of the entered txt values or comboboxes Index have been changed and the uptade button is clicked.

    Thanks!!

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,926

    Re: Make Visual Basic Wait for User input

    You wouldn't. You would end a function and then call a function when the appropriate event is raised, e.g. a Button Click. Please provide a full and clear description of exactly what you want to achieve from a functionality point of view and then we can tell you how to achieve it from a code point of view.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3
    Fanatic Member
    Join Date
    Jul 2009
    Posts
    629

    Re: Make Visual Basic Wait for User input

    You could do this:
    Code:
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            button1_clicked = True
        End Sub
        Private button1_clicked As Boolean = False
    
        Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
            myfunc()
        End Sub
    
        Private Sub myfunc()
            MsgBox("Start of function, waiting for button click")
            Do While button1_clicked = False
                Threading.Thread.Sleep(50)
                Application.DoEvents()
            Loop
            MsgBox("End of function, button is clicked")
        End Sub
    But .NET has a nice event system, best is to run the next code under the button click event instead.

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