如何将Visual Basic6列表框数据保存到文本文件中 [英] How can i Save Visual basic6 Listbox Data into text File
本文介绍了如何将Visual Basic6列表框数据保存到文本文件中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在处理一个项目,并希望将列表框数据保存到文本文件中。但是为此我没有Mind.please帮助我。
我有一个带有Items.I的列表框想要将所有项目保存到文本文件中。
谢谢
解决方案
尝试类似...
Dim FileNumber As Integer = FreeFile()
FileOpen(FileNumber, d:\ path \\ \\ filename.txt,OpenMode.Output)
对于 每个项< span class =code-keyword>作为 对象 在 ListBox1.Items
PrintLine(FileNumber,Item.ToString)
下一步
FileClose(FileNumber)
或,
私有 Sub btnSave_Click( ByVal sender 作为系统。对象, ByVal e As System.EventArgs)句柄 btnSave.Click
使用 SW 作为 新 IO.StreamWriter( d:\ListBox1.txt, True )
For 每个 itm As 字符串 在 我 .ListBox1.Items
SW.WriteLine(itm)
下一步
结束 使用
结束 子跨度>
I am working a project and want to save Listbox Data into a Text File.but for this i have no Mind.please help me .
I have a Listbox with Items.I want to save all items into a text file.
Thanks
解决方案
Try something like..
Dim FileNumber As Integer = FreeFile() FileOpen(FileNumber, "d:\path\filename.txt", OpenMode.Output) For Each Item As Object In ListBox1.Items PrintLine(FileNumber, Item.ToString) Next FileClose(FileNumber)
Or,
Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click Using SW As New IO.StreamWriter("d:\ListBox1.txt", True) For Each itm As String In Me.ListBox1.Items SW.WriteLine(itm) Next End Using End Sub
这篇关于如何将Visual Basic6列表框数据保存到文本文件中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文