VB6 Save ListBox to TXT File?
Hi, i am designing a tool to ping an ip range to see what ip address are taken, the results are listed in a list box. I want to be able to export them to a txt file, however i have only been able to hardcode the txt file path name, also the txt file has to be created previously or it wont save.
Cany anyone show/tell me how to use the common dialog control Showsave to let me select the directory and save the text file?
Heres the code i was using atm to write to the txt file, the check box was used to filter out results that were not a sucessful ping.
any help much appreciated
If chkFailed.Value = 1 Then
Dim WriteLineTextFile2 As String
Const ForReading1 = 1, ForWriting1 = 2
Dim fso1, f1
Set fso1 = CreateObject("Scripting.filesystemobject")
Set f1 = fso1.opentextfile("H:\ip.txt", ForWriting1)
For i1 = 0 To lsbrange.ListCount - 1
lsbrange.ListIndex = i1
Dim str As String
For i = 1 To Len(lsbrange.Text)
strtmp = Mid(lsbrange.Text, i, 5)
If strtmp = "- S" Then
str = Mid(lsbrange.Text, i + 4, 10)
Dim WriteLineTextFile As String
Const ForReading = 1, ForWriting = 2
Dim fso, f
Set fso = CreateObject("Scripting.filesystemobject")
Set f = fso.opentextfile("H:\ip.txt", ForWriting)
For i = 0 To lsbrange.ListCount - 1
lsbrange.ListIndex = i
If i = lsbrange.ListCount - 1 Then
MsgBox ("Export Complete")