VB怎麼把列表框内容自动存取为TXT文档,又如何把TXT内容导入到列表框
1个回答
展开全部
Option Explicit
Private Sub Command1_Click()
'保存列表框内容
Dim i As Integer
Open "d:\list1.txt" For Output As #1 '自己设置保存路径
For i = 0 To List1.ListCount - 1
Print #1, List1.List(i)
Next
Close #1
End Sub
Private Sub Command2_Click()
'打开文件到列表框
Dim strLine As String
Open "d:\list1.txt" For Input As #1
Do While Not EOF(1)
Line Input #1, strLine '按行添加
List1.AddItem strLine
Loop
close
End Sub
Private Sub Command1_Click()
'保存列表框内容
Dim i As Integer
Open "d:\list1.txt" For Output As #1 '自己设置保存路径
For i = 0 To List1.ListCount - 1
Print #1, List1.List(i)
Next
Close #1
End Sub
Private Sub Command2_Click()
'打开文件到列表框
Dim strLine As String
Open "d:\list1.txt" For Input As #1
Do While Not EOF(1)
Line Input #1, strLine '按行添加
List1.AddItem strLine
Loop
close
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询