![]() |
Problem with Excel list box
Hello, I am trying to learn how to work with the list of
informtion in a listbox. I have added the list using AddItem. Now I want to print that list to file. The following code does not work, and has my notes. I would appreciate any suggestions on how to make the print statement work, but also how to move data into this two- column listbox list. Thank you Keith var3 = ListBox1.ListCount Close #1 i = 0 Open "c:\test\temp.txt" For Output As #1 For i = 0 To var3 - 1 'Each In ListBox1 'i = i + 1 Print #1, i 'Print #1, ListBox1(i).Value ' not accepted at run time 'Print #1, ListBox1(i, 1).Value ' not accepted at run time 'Print #1, ListBox1(i, 0).Value ' not accepted 'Print #1, ListBox1(i).Text Next i Close #1 |
Problem with Excel list box
NOT
ListBox1(i).Value With Listbox1 For i = 0 to .ListCount -1 Print #1, .List(i) Next Close End With '' note the "." before ListCount and also List "Keith" wrote: Hello, I am trying to learn how to work with the list of informtion in a listbox. I have added the list using AddItem. Now I want to print that list to file. The following code does not work, and has my notes. I would appreciate any suggestions on how to make the print statement work, but also how to move data into this two- column listbox list. Thank you Keith var3 = ListBox1.ListCount Close #1 i = 0 Open "c:\test\temp.txt" For Output As #1 For i = 0 To var3 - 1 'Each In ListBox1 'i = i + 1 Print #1, i 'Print #1, ListBox1(i).Value ' not accepted at run time 'Print #1, ListBox1(i, 1).Value ' not accepted at run time 'Print #1, ListBox1(i, 0).Value ' not accepted 'Print #1, ListBox1(i).Text Next i Close #1 |
Problem with Excel list box
You need to use the .Column property, e.g:
Print #1, ListBox1.Column(0,i) ' Prints row i-1, column 1 Note that the column and row values are 0 based; the first one is numbered 0 "Keith" wrote: Hello, I am trying to learn how to work with the list of informtion in a listbox. I have added the list using AddItem. Now I want to print that list to file. The following code does not work, and has my notes. I would appreciate any suggestions on how to make the print statement work, but also how to move data into this two- column listbox list. Thank you Keith var3 = ListBox1.ListCount Close #1 i = 0 Open "c:\test\temp.txt" For Output As #1 For i = 0 To var3 - 1 'Each In ListBox1 'i = i + 1 Print #1, i 'Print #1, ListBox1(i).Value ' not accepted at run time 'Print #1, ListBox1(i, 1).Value ' not accepted at run time 'Print #1, ListBox1(i, 0).Value ' not accepted 'Print #1, ListBox1(i).Text Next i Close #1 |
All times are GMT +1. The time now is 10:29 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com