Computing.Net > Forums > Programming > Inputbox question

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Inputbox question

Reply to Message Icon

Name: Samantha
Date: December 10, 2003 at 13:17:55 Pacific
OS: 128
CPU/Ram: 1 Gig
Comment:

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



Sponsored Link
Ads by Google

Response Number 1
Name: Stuart
Date: December 10, 2003 at 15:25:33 Pacific
Reply:

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


0

Response Number 2
Name: wsd
Date: January 9, 2004 at 00:51:58 Pacific
Reply:

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 Sub

This is what you would like to do. Hope it will work.


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More


Yes, another C currency c... Running a program on star...



Post Locked

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


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Inputbox question

easy VB6 questions www.computing.net/answers/programming/easy-vb6-questions/5807.html

Find Factorial in Vb Using InputBox www.computing.net/answers/programming/find-factorial-in-vb-using-inputbox/5841.html

BASIC question www.computing.net/answers/programming/basic-question/8383.html