Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creating list items from text boxes?

Status
Not open for further replies.

r3b00t

Technical User
Aug 13, 2002
45
GB
Hi guys

Ive got two forms, on the first one ive got three text boxes and a submit button and on the second a list box.
What i want is when the user clicks on the submit button for all the text in the three boxes to be added to the list box in a presentable way.

Can anyone help please?

Cheers

r3b00t
 
You could do it very simply with coding along the lines of:

Private Sub Submit_Click()

Form2.List1.AddItem Text1.Text
Form2.List1.AddItem Text2.Text
Form2.List1.AddItem Text3.Text

Form2.Show

End Sub

Hope it helps
Asjeff
 
Thanx for the reply, just one more thing how do i put a couple of spaces between each entry on the one line to make it easy to read?

Thanx again

r3b00t
 
Private Sub Submit_Click()

Form2.List1.AddItem Text1.Text & " "
Form2.List1.AddItem Text2.Text & " "
Form2.List1.AddItem Text3.Text & " "

Form2.Show

End Sub

but it is worth noting that the above code should add each entry to a separate line

Asjeff
 
Form2.List1.AddItem Text1.Text & spc(2) & Text2.Text & spc(2) & Text3.Text

will get it on one line with spaces in between Let me know if this helps
________________________________________________________________
If you are worried about how to post, please check out FAQ222-2244 first

'There are 10 kinds of people in the world: those who understand binary, and those who don't.'
 
Thats what i thought too but i get a message saying 'Complie Error Expected: Expression' when i put this line of code in:

frmCallbacks.List1.AddItem txtCaseRef.Text & spc(2) & txtDate.Text & spc(2) & txtTime.Text

Any ideas guys?

Cheers

r3b00t
 
Thats what i thought too but i get a message saying 'Complie Error Expected: Expression' when i put this line of code in:

frmCallbacks.List1.AddItem txtCaseRef.Text & spc(2) & txtDate.Text & spc(2) & txtTime.Text

Any ideas guys?

Cheers

r3b00t

ps I thought the spc command could only be used with the print statement
 
Guys i got it sorted with:

frmCallbacks.List1.AddItem txtCaseRef.Text & " " & txtDate.Text & " " & txtTime.Text

Cheers guys

r3b00t
 
Sorry I mentally slipped back to Basic. Code should have read Space(2) not spc(2)

I just put it down to OLD AGE! Let me know if this helps
________________________________________________________________
If you are worried about how to post, please check out FAQ222-2244 first

'There are 10 kinds of people in the world: those who understand binary, and those who don't.'
 
OK guys, sorry about this but i got another question.
When an item is selected in the list how could i go about deleting this using a command button?

Regards

r3b00t
 
It's often best to start a new question in a new thread, otherwise it may get overlooked.

Try this:
Code:
Private Sub Command1_Click
List1.RemoveItem (List1.ListIndex)
End Sub
Let me know if this helps
________________________________________________________________
If you are worried about how to post, please check out FAQ222-2244 first

'There are 10 kinds of people in the world: those who understand binary, and those who don't.'
 
Thats great guys, thanx alot all of you!

Cheers

r3b00t
 

Do this instead:
frmCallbacks.List1.AddItem txtCaseRef.Text & vbTab & txtDate.Text & vbTab & txtTime.Text
[/b][/i][/u]*******************************************************
General remarks:
If this post contains any suggestions for the use or distribution of code, components or files of any sort, it is still your responsibility to assure that you have the proper license and distribution rights to do so!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top