怎样把文本文件的内容读入ListBox控件中?
- 提问者网友:难遇难求
- 2021-03-07 08:42
"123123"
"asdfgh"
"asdf"
如何读入并且自动分列呢?
- 五星知识达人网友:孤独的牧羊人
- 2021-03-07 09:09
Open "d:\mydate.txt" For Input As #1
Do While Not EOF(1)
Line Input #1, st
List1.AddItem st
Loop
Close #1
End Sub
- 1楼网友:持酒劝斜阳
- 2021-03-07 10:31
- 2楼网友:北方的南先生
- 2021-03-07 10:18
private sub addcolor_click(byval sender as system.object, byval e as system.eventargs) handles addcolor.click using sw as streamwriter = new streamwriter("color.txt") listbox1.items.add(textbox2.text) for i = 0 to listbox1.items.count - 1 sw.writeline(listbox1.items.item(i)) next sw.close() end using end sub
private sub readcolor_click(byval sender as system.object, byval e as system.eventargs) handles readcolor.click using sr as streamreader = new streamreader("color.txt") dim line as string while not sr.endofstream line = sr.readline() listbox1.items.add(line) end while sr.close() end using end sub