Click to See Complete Forum and Search --> : ListBox Question
Smie
Dec 10th, 1999, 02:32 AM
How would I make a textbox = list1's 3rd selection? For example, when a button is pressed, the 3rd value, or 3rd item from the top(not sure what to call it), pops into the textbox, i have a good idea on what to do, but nothing will work, please help, thanx
QWERTY
Dec 10th, 1999, 02:47 AM
Try this:
Add a ListBox, CommandButton and TextBox to your form, then paste this code:
Option Explicit
Public Index As Integer
Private Sub Command1_Click()
Text1.Text = List1.List(Index)
End Sub
Private Sub Form_Load()
Dim I As Integer
With List1
For I = 1 To 10
.AddItem I
Next I
End With
End Sub
Private Sub List1_Click()
Index = List1.ListIndex
End Sub
I hope this will help
------------------
Visual Basic Programmer
------------------
PolComSoft
You will hear a lot about it.
Aaron Young
Dec 10th, 1999, 02:54 AM
Do you mean how do you access the 3rd Item Down from the Visible Top of the Listbox?
Private Sub Command1_Click()
If List1.TopIndex + 2 < List1.ListCount Then
Text1 = List1.List(List1.TopIndex + 2)
Else
Text1 = List1.List(List1.ListCount - 1)
End If
End Sub
Otherwise, if you mean how do you access the 3rd Item Period..
Text1 = List1.List(2)
------------------
Aaron Young
Analyst Programmer
aarony@redwingsoftware.com
adyoung@win.bright.net
Smie
Dec 10th, 1999, 03:02 AM
Im a little confused, what you gave me, even though i appreciate your help, was not what i was looking for, maybe if im more specific:
Say i have 10 items in the listbox. I also have 10 textboxes. What would i do, so at a push of a button, the each listbox item, is now in a seprate textbox.
Smie
Dec 10th, 1999, 03:05 AM
Thanks aaron, thats what ive been looking for
QWERTY
Dec 10th, 1999, 03:06 AM
If that's your problem then use this:
Create an array of 10 textboxes, add 10 items to a listbox and paste this code:
Private Sub Command1_Click()
Dim I As Integer
For I = 0 to List1.ListCount - 1
Text1(I).Text = List1.List(I)
Next I
End Sub
Hope This will help
------------------
Visual Basic Programmer
------------------
PolComSoft
You will hear a lot about it.
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.