DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 1 of 1

Hybrid View

  1. #1
    Join Date
    Jan 2005

    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.

    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)
                        f1.writeline (lsbrange.Text)
                        Exit For
                    End If
                Next i
            Next i1
        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
            f.writeline (lsbrange.Text)
            If i = lsbrange.ListCount - 1 Then
            End If
        Next i
    End If
    MsgBox ("Export Complete")
    End Sub
    any help much appreciated


    edit - sorry i posted this in the wrong forum, could a mod please remove
    Last edited by N4N01D; 01-06-2005 at 06:57 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
Latest Articles
Questions? Contact us.
Web Development
Latest Tips
Open Source

   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center

We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.