所以我想把所有listbox1项目都放到一个文本文件中,然后我不断收到错误"' item'不是' String()'"的成员
我收到错误:w.WriteLine(ListBox1.items.Item(i))
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
IO.Directory.CreateDirectory("C:\ProxyGrabber")
Dim w As New IO.StreamWriter("C:\ProxyGrabbe\test.txt")
Dim i As Integer
For i = 0 To ListBox1.items.Count - 1
w.WriteLine(ListBox1.items.Item(i))
Next
w.Close()
End Sub
答案 0 :(得分:0)
ListBox1.items.Item(i)
返回一个对象类型。如果列表框项只是字符串,那么您需要做的就是更改
w.WriteLine(ListBox1.items.Item(i))
到
w.WriteLine(CType(ListBox1.Items.Item(i), String))