|
-
Jan 24th, 2010, 02:13 PM
#1
Thread Starter
Addicted Member
[RESOLVED] How to take text from listbox and put in textbox?
How do i take the text from a listbox and put it in a textbox?
-
Jan 24th, 2010, 02:16 PM
#2
Fanatic Member
Re: How to take text from listbox and put in textbox?
well, if you use the Select Case function, you could say
Code:
Select Case lstWhatever
Case0 "Hi"
txtWhatever.text="Hi"
Case1 "Hello"
txtWhatever.text="Hello"
End Select
Like that.
-
Jan 24th, 2010, 02:19 PM
#3
Re: How to take text from listbox and put in textbox?
What do you want to take from the listbox? All of the listitems or specific listitems?
List1.List(0) is the 1st item, List1.List(1) is 2nd item & so on.
-
Jan 24th, 2010, 02:28 PM
#4
Thread Starter
Addicted Member
Re: How to take text from listbox and put in textbox?
Id like to take all the items LaVolpe if you could help please thanks.
-
Jan 24th, 2010, 02:34 PM
#5
Thread Starter
Addicted Member
Re: How to take text from listbox and put in textbox?
I have tried
Code:
Private Sub Command1_Click()
Dim i As Integer
For i = 0 To List1.ListCount
i = i + 1
Text1.Text = List1.List(i)
Next i
End Sub
But text1 just stays blank.
-
Jan 24th, 2010, 03:34 PM
#6
Re: How to take text from listbox and put in textbox?
Almost. A couple of things
1. The loop variable, i, is automatically incremented in a For:Next loop. Do not increment it yourself.
2. Your textbox must have MultiLine=True to display more than one line. Also when you append text and want a new line, you should use vbNewLine
3. List items are zero-bound, this means you cannot loop to List1.ListCount, must be List1.ListCount-1
Tweaking your loop code only
Code:
For i = 0 To List1.ListCount - 1
Text1.Text = Text1.Text & List1.List(i) & vbNewLine
Next i
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
|