|
-
Dec 20th, 2005, 06:26 PM
#1
Thread Starter
Junior Member
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.
-
Dec 20th, 2005, 06:30 PM
#2
Hyperactive Member
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?
-
Dec 20th, 2005, 06:47 PM
#3
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.
-
Dec 21st, 2005, 12:43 AM
#4
Thread Starter
Junior Member
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.
-
Dec 21st, 2005, 08:43 PM
#5
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:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
For Each item As Object In Me.ListBox1.Items
If Me.ListBox1.GetItemText(item) = Me.TextBox1.Text Then
MessageBox.Show("We have a match!")
Exit For
End If
Next item
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|