Click here to Skip to main content
15,881,173 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I want a user to enter numbers in multiple time through an input box and i want to show all the numbers in a listbox

What I have tried:

I have not try anytin i just want to know i will do it
Posted
Updated 13-May-20 22:15pm

These are the type of steps you need - we do not write your code for you

1) create a form
2) on the form place a text box - I'll assume it's name is textbox1
3) create a label next to the text box with 'input' as the text
4) on the form create a list box - I'll assume it's name is listbox1
5) create a label next to the list box with 'data' as the text
6) add some code the the textbox1's 'On Enter' event to add the data to the list box - it will be 'something like' listbox1.Items.Add(textbox1.Text)

6) edited .. you should have something like this
Private Sub textbox1_KeyPress (KeyAscii As Integer)
    If KeyAscii = 13 Then  ' The ENTER key.
        listbox1.Items.Add(textbox1.Text)
    End If
End Sub

but obviously you'll need to consult your VB6 textbook or reference for the specifics
 
Share this answer
 
v2
Comments
[no name] 14-May-20 6:40am    
Alright thanks sir. But will listbox1.items.add(textbox1.Text) be inside the loop or outside the loop?
Garth J Lancaster 14-May-20 8:22am    
not sure what you mean 'loop' - there is no loop - you enter digits into the textbox, push the enter key, and then those digits ie number get added to the listbox (nb, you should validate that the value in textbox1 is actually a number ... I've modified my original answer taking VB6 into account at point 6, but it will still require work from you to fill in the blanks etc
CHill60 14-May-20 8:34am    
5'd - Not just for being able to remember VB6 :-)
[no name] 14-May-20 9:32am    
Am sorry sir, basically what i want to do is that i want to use an array, the user will enter the number in the array and display the array in the listbox(in a single line) or textbox.
can u help me on it?
Garth J Lancaster 14-May-20 10:08am    
I'm sorry - I answered the question you asked - you haven't shown any work you've done or actually done any work, you've just changed the requirements - I think you should go back to your teacher/whatever and ask for more help
Hint: use the TextBox KeyPress event, see example here: https://www.experts-exchange.com/questions/21781639/vb6-how-capture-enter-key-press.html[^]
 
Share this answer
 
Comments
Maciej Los 14-May-20 13:55pm    
5ed!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900