| Author |
Message |
elise_moss
Guest
|
Posted:
Thu Mar 17, 2005 12:48 am Post subject:
list box item |
|
|
I am working in VB6.
I want to get the itemno for the list text selected from a list box. I want to be able to correspond some data from two text files...one txt file populates the list box and the second txt file lists a corresponding file that would be opened based on the line selected in the list box.
I know it is something like Set itemno = List.ListItem(?)
Thanks,
Elise Moss
www.mossdesigns.com
|
|
| Back to top |
|
 |
TomD
Guest
|
Posted:
Thu Mar 17, 2005 2:11 am Post subject:
Re: list box item |
|
|
From the help files:
"elise_moss" <nospam@address.withheld> wrote in message
news:5379419.1111002543729.JavaMail.jive@jiveforum2.autodesk.com...
| Quote: | I am working in VB6.
I want to get the itemno for the list text selected from a list box. I
want to be able to correspond some data from two text files...one txt file
populates the list box and the second txt file lists a corresponding file
that would be opened based on the line selected in the list box.
I know it is something like Set itemno = List.ListItem(?)
Thanks,
Elise Moss
www.mossdesigns.com |
|
|
| Back to top |
|
 |
Anne Brown
Guest
|
Posted:
Thu Mar 17, 2005 2:28 am Post subject:
Re: list box item |
|
|
Tom -
Nothing attached?
---
Anne Brown
Discussion Groups Administrator
Autodesk, Inc.
TomD wrote:
| Quote: |
From the help files: |
|
|
| Back to top |
|
 |
Paul Richardson
Guest
|
Posted:
Thu Mar 17, 2005 2:29 am Post subject:
Re: list box item |
|
|
something like this. Same idea in the click event
to open the file necessary.
Private Sub UserForm_Initialize()
Dim txtFile As Integer: txtFile = FreeFile
Dim nextLine As String
Open "c:\listBoxData.txt" For Input As txtFile
Do Until EOF(txtFile)
Line Input #txtFile, nextLine
ListBox1.AddItem nextLine
Loop
End Sub
"elise_moss" <nospam@address.withheld> wrote in message
news:5379419.1111002543729.JavaMail.jive@jiveforum2.autodesk.com...
| Quote: | I am working in VB6.
I want to get the itemno for the list text selected from a list box. I
want to be able to correspond some data from two text files...one txt file
populates the list box and the second txt file lists a corresponding file
that would be opened based on the line selected in the list box.
I know it is something like Set itemno = List.ListItem(?)
Thanks,
Elise Moss
www.mossdesigns.com |
|
|
| Back to top |
|
 |
Frank Oquendo
Guest
|
Posted:
Thu Mar 17, 2005 2:38 am Post subject:
Re: list box item |
|
|
elise_moss wrote:
| Quote: | I want to get the itemno for the list text selected from a list box. I want to be able to correspond some data from two text files...one txt file populates the list box and the second txt file lists a corresponding file that would be opened based on the line selected in the list box.
|
Might it be easier to read both files at the same time? You could use
the index number from the list as an index into a collection or dictionary. |
|
| Back to top |
|
 |
Paul Richardson
Guest
|
Posted:
Thu Mar 17, 2005 3:19 am Post subject:
Re: list box item |
|
|
"Paul Richardson" <prichardson@adelphia.net> wrote in message
news:4238a532$1_1@newsprd01...
| Quote: | something like this. Same idea in the click event
to open the file necessary.
Private Sub UserForm_Initialize()
Dim txtFile As Integer: txtFile = FreeFile
Dim nextLine As String
Open "c:\listBoxData.txt" For Input As txtFile
Do Until EOF(txtFile)
Line Input #txtFile, nextLine
ListBox1.AddItem nextLine
Loop
End Sub
"elise_moss" <nospam@address.withheld> wrote in message
news:5379419.1111002543729.JavaMail.jive@jiveforum2.autodesk.com...
I am working in VB6.
I want to get the itemno for the list text selected from a list box. I
want to be able to correspond some data from two text files...one txt
file populates the list box and the second txt file lists a corresponding
file that would be opened based on the line selected in the list box.
I know it is something like Set itemno = List.ListItem(?)
Thanks,
Elise Moss
www.mossdesigns.com
|
|
|
| Back to top |
|
 |
Paul Richardson
Guest
|
Posted:
Thu Mar 17, 2005 3:20 am Post subject:
Re: list box item |
|
|
make sure you close the file alos...
Close txtFile
"Paul Richardson" <prichardson@adelphia.net> wrote in message
news:4238a532$1_1@newsprd01...
| Quote: | something like this. Same idea in the click event
to open the file necessary.
Private Sub UserForm_Initialize()
Dim txtFile As Integer: txtFile = FreeFile
Dim nextLine As String
Open "c:\listBoxData.txt" For Input As txtFile
Do Until EOF(txtFile)
Line Input #txtFile, nextLine
ListBox1.AddItem nextLine
Loop
End Sub
"elise_moss" <nospam@address.withheld> wrote in message
news:5379419.1111002543729.JavaMail.jive@jiveforum2.autodesk.com...
I am working in VB6.
I want to get the itemno for the list text selected from a list box. I
want to be able to correspond some data from two text files...one txt
file populates the list box and the second txt file lists a corresponding
file that would be opened based on the line selected in the list box.
I know it is something like Set itemno = List.ListItem(?)
Thanks,
Elise Moss
www.mossdesigns.com
|
|
|
| Back to top |
|
 |
TomD
Guest
|
Posted:
Thu Mar 17, 2005 3:24 am Post subject:
Re: list box item |
|
|
Inadvertant key combination mistake.
No help, just snide comment?
"Anne Brown" <discussion.support@autodesk.com> wrote in message
news:4238A4F7.7CD49D57@autodesk.com...
| Quote: | Tom -
Nothing attached?
---
Anne Brown
Discussion Groups Administrator
Autodesk, Inc.
TomD wrote:
From the help files: |
|
|
| Back to top |
|
 |
elise_moss
Guest
|
Posted:
Fri Mar 18, 2005 9:43 pm Post subject:
Re: list box item |
|
|
None of you answered my question. I know how to populate the listbox using the text file using the methods in your responses.
I want to know once the user has made the selection...I can get the text value, but I can not get the item value (whether it was line 1 or line 50). |
|
| Back to top |
|
 |
Alfred NESWADBA
Guest
|
Posted:
Fri Mar 18, 2005 10:19 pm Post subject:
Re: list box item |
|
|
ListBox.ListIndex
and if it's not what you wanted maybe a clearer descripton will help
- alfred -
In article <11527741.1111164237977.JavaMail.jive@jiveforum2.autodesk.com>, nospam@address.withheld says...
| Quote: | None of you answered my question. I know how to populate the listbox using the text file using the methods in your responses.
I want to know once the user has made the selection...I can get the text value, but I can not get the item value (whether it was line 1 or line 50).
|
|
|
| Back to top |
|
 |
elise_moss
Guest
|
Posted:
Fri Mar 18, 2005 10:27 pm Post subject:
Re: list box item |
|
|
No, that is exactly what I want, but I am still getting an error.
Dim itemno As Integer
Set itemno = lst.Listindex
gets me an object required error. |
|
| Back to top |
|
 |
Frank Oquendo
Guest
|
Posted:
Fri Mar 18, 2005 10:35 pm Post subject:
Re: list box item |
|
|
elise_moss wrote:
| Quote: | None of you answered my question.
|
Not a very gracious way to ask for help, Ms. Moss. |
|
| Back to top |
|
 |
Frank Oquendo
Guest
|
Posted:
Fri Mar 18, 2005 10:36 pm Post subject:
Re: list box item |
|
|
elise_moss wrote:
| Quote: | No, that is exactly what I want, but I am still getting an error.
Dim itemno As Integer
Set itemno = lst.Listindex
gets me an object required error.
|
That's to be expected. 'itemno' is not an object nor does the ListIndex
property return an object reference.
Drop the Set keyword and change itemno to a Long so you don't encounter
overflow errors. |
|
| Back to top |
|
 |
elise_moss
Guest
|
Posted:
Fri Mar 18, 2005 10:40 pm Post subject:
Re: list box item |
|
|
| I got it...thanks...all I needed was the ListIndex and I could take it from there. |
|
| Back to top |
|
 |
Paul Richardson
Guest
|
Posted:
Fri Mar 18, 2005 10:45 pm Post subject:
Re: list box item |
|
|
If you couldn't figure that out I assumed you didn't
know the other either..But you welcome!
"elise_moss" <nospam@address.withheld> wrote in message
news:22001839.1111167673698.JavaMail.jive@jiveforum2.autodesk.com...
| Quote: | I got it...thanks...all I needed was the ListIndex and I could take it from
there. |
|
|
| Back to top |
|
 |
|
|
|
|