vb listbox如何导出到txt
我有个LISTBOX如何把里面的全部数据导出到我选择的txt文件里面.我导入是这样做的,那导出应该怎样呢.
Dim d As String
CommonDialog2.Filter = "所有文件(*.*)|*.*"
CommonDialog2.ShowOpen
d = CommonDialog2.FileName
Open d For Input As #1
Do While Not EOF(1)
Line Input #1, temp
List1.AddItem temp
Loop
Close #1
以上是导入的如何才能改成全部导出,列表里面的所有.
[解决办法]
Private Sub Command1_Click()
Open "c:\temmp.txt" For Output As #1
Dim i As Integer
For i = 0 To List1.ListCount - 1
Print #1, List1.List(i)
Next
Close #1
End Sub
Private Sub Form_Load()
Dim i As Integer
For i = 0 To 9
List1.AddItem "item" & i
Next
End Sub