VB怎麼把列表框内容自动存取为TXT文档,又如何把TXT内容导入到列表框
发布网友
发布时间:2023-12-24 11:25
我来回答
共1个回答
热心网友
时间:2024-08-07 15:52
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