Results 1 to 5 of 5

Thread: Waiting for input.

  1. #1

    Thread Starter
    Junior Member guitarhero14's Avatar
    Join Date
    Nov 2005
    Posts
    23

    Waiting for input.

    I have a list box to display the choices the user has and a text box below to recieve the users input. I cant seem to think of a way for the program to wait for input in the textbox besides using a InputBox. I hope i explained this well. Thank you for your help in advance.

  2. #2
    Hyperactive Member dRAMmer's Avatar
    Join Date
    Oct 2001
    Location
    strangelans
    Posts
    463

    Re: Waiting for input.

    What do you mean by wait? Is there something that you would like to do after user-input? Is it not like the same as: program-waits-for-input-then-user-clicks-button-then-program-do-something? Or probably program waits for input then after desired length in textbox is reach program do something?
    live, code and die...

  3. #3
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Waiting for input.

    You have to use a Button to display the InputBox and then dismiss it again anyway, so just provide a Button for the user to press when they have finished entering data, as dRAMmer suggested. Also, please be a little more specific in your questions. We're trying to help you so please don't make us guess what the situation is.
    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

  4. #4

    Thread Starter
    Junior Member guitarhero14's Avatar
    Join Date
    Nov 2005
    Posts
    23

    Re: Waiting for input.

    Sorry I was not clear enough. What i would like is the user to enter in a value in TextBox1 and then click the submit button and have the program run through an IF statement. The only problem is that there is going to many different instances of this process with different items in the listbox and i am at a loss. I have included a pic to further explain. Thanks for the input.
    Last edited by guitarhero14; Dec 21st, 2005 at 01:31 AM.

  5. #5
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Waiting for input.

    You still haven't really explained what you want to happen. You can easily use a For loop to iterate over the items in the ListBox, regardless of what they are or how many there are, and compare them to the Text in the ListBox:
    VB Code:
    1. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    2.         For Each item As Object In Me.ListBox1.Items
    3.             If Me.ListBox1.GetItemText(item) = Me.TextBox1.Text Then
    4.                 MessageBox.Show("We have a match!")
    5.                 Exit For
    6.             End If
    7.         Next item
    8.     End Sub
    Is that the sort of thing you want to do? This is a simple example but the principle can be extrapolated to any number of scenarios. You could use a For loop instead of a For Each loop if you need to know the index of the matching item. I've also used GetItemText to account for the fact that a ListBox can contain items of any type. If you have added String objects to the ListBox then you can just use the items themselves directly, but using GetItemText is a good policy as it will work in absolutely any case.
    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

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