How to write to text file instead of viewing data in listview? (1 Viewer)

tony007

Registered User.
Local time
Yesterday, 19:17
Joined
Jun 30, 2005
Messages
53
Hi all . I have a search result that is outputed to listview in my vb6 form and i wonder how i can write the output data in to text file which is readable instead of showing it listview. I be happy if an expert show me how .Thanks


Here is my code that displays data in lisview . I want the data to be writen in text file instead:

Code:
Private Sub cReg_SearchFound(ByVal sRootKey As String, ByVal sKey As String, ByVal sValue As Variant, ByVal lFound As FOUND_WHERE)
   Dim lvItm As ListItem
   Select Case lFound
         Case FOUND_IN_KEY_NAME
              sTemp = "KEY_NAME"
         Case FOUND_IN_VALUE_NAME
              sTemp = "VALUE NAME"
         Case FOUND_IN_VALUE_VALUE
              sTemp = "VALUE VALUE"
   End Select
   [B]With ListView1
       Set lvItm = .ListItems.Add(, , sTemp)
       lvItm.SubItems(1) = sRootKey
       lvItm.SubItems(2) = sKey
       lvItm.SubItems(3) = sValue
    
   End With[/B]   Set lvItm = Nothing
End Sub
 

supercharge

Registered User.
Local time
Yesterday, 19:17
Joined
Jun 10, 2005
Messages
215
Code:
Private Sub cReg_SearchFound(ByVal sRootKey As String, ByVal sKey As String, ByVal sValue As Variant, ByVal lFound As FOUND_WHERE)
   Dim lvItm As ListItem
   Select Case lFound
         Case FOUND_IN_KEY_NAME
              sTemp = "KEY_NAME"
         Case FOUND_IN_VALUE_NAME
              sTemp = "VALUE NAME"
         Case FOUND_IN_VALUE_VALUE
              sTemp = "VALUE VALUE"
   End Select
   [B]With ListView1
       Set lvItm = .ListItems.Add(, , sTemp)
       lvItm.SubItems(1) = sRootKey
       lvItm.SubItems(2) = sKey
       lvItm.SubItems(3) = sValue
    
   End With[/B]   Set lvItm = Nothing

   [COLOR="Blue"]
   ' VB 6 Codes, assuming Results.txt already exists
    Dim txtFile as string
    txtFile = App.path & "\Results.txt"
    Open FileName For Input As #1
    Open FileName For Append As #1
              Print #1, WHATEVER NEEDED TO BE WRITTEN
     Close #1
   [/COLOR]
End Sub
 

Users who are viewing this thread

Top Bottom