Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hi,
How would I go about doing a for next loop with and inputbox. I need the user to put a number in the inputbox then automatically its adds it to a listbox. This will go on and on until there's a duplicate in the listbox and take you to the form with the listbox.
Best Regards
Samantha

Get rid of the InputBox, its the biggest abonomation that ever entered Visual Basic. I assume it is Visual Basic your are using. Putting the InputBox inside a loop is always going to be probalamatic because it displays a model form.
It is easy enough to write your own input routine using a text box and a seperate form. Gives you more control over what can be entered. Then it will be easy to incorporate it into a loop.
Stuart

Hi,
Try this:
Add a listbox to a form. In Project menu, select Project1 Properties. At general tab, change Startup Object to Sub Main. Click Ok. In Project menu, select Add Module and select new module. Open the module1 code windows. In Tools menu, select add new procedure as Sub Main and write these:Public Sub Main()
Dim i As Integer
Dim Dta As String
Dim SameData As Boolean
Do
Dta = InputBox("Number: ")
For i = 0 To Form1.List1.ListCount - 1 Step 1
If Dta = Form1.List1.List(i) Then
SameData = True
Exit For
End If
Next i
If Not SameData Then
Form1.List1.AddItem Dta
Else
Exit Do
End If
Loop While 1
Form1.Show
End SubThis is what you would like to do. Hope it will work.

![]() |
Yes, another C currency c...
|
Running a program on star...
|

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |