Good evening,

   I'm having problems when trying to save a listbox in a .txt file, follow the code;

         Dim Caminho As New IO.StreamWriter("C:\Test\Arquin.txt")
         Dim i As Integer
         For i = 0 To ListBox1.Items.Count - 1

The following error occurs:

'Item' is not a member of 'System.Array'

(I am Brazilian, maybe my English is half wrong because I used the google translator)


For Each line As String In ListBox1.Items

Created the file, but when I see has nothing recorded in the file

If there are string values the code line should be similar to listBox.Items[i].ToString() Try that.

A ListBox, by definition, contains text. You don't have to convert to String. Try replacing




or put a breakpoint at that line and check the values. But don't forget to add


after the loop.

It did not work ...

I think it is not working because I was wearing a theme in to change the appearance

Instead of Caminho.WriteLine(ListBox1.Items.Item(i)) use Caminho.WriteLine(ListBox1.Items(i)) which can return you the value of the lisboxitem at the position of i.

I've already tried the code I suggested and it writes the lines of text to the file as requested.

Did tests and found that the problem is that I was not going through the listbox, maybe it's because my listbox is of topics that I put in

I was not going through the listbox

I don't know what you mean by that.