I am trying to write the contents of a listbox into a text file, but I am having difficulty. The code executes error free, however at the end of it I cannot find the created text file (if it even is being created).
VB Code:
Private Sub cmdTextfile_Click() Dim strFilename As String Dim intMessage As Integer Dim i As Integer If lstResults.List(0) <> "" Then strFilename = InputBox("Input filename for new output textfile", "Input Filename") strFilename = strFilename & ".txt" Open strFilename For Output As #1 i = 0 Do Print #1, lstResults.List(i) i = i + 1 Loop Until i = lstResults.ListCount + 1 Close #1 MsgBox ("Textfile has been created") Else MsgBox ("There are no output values to output to file") End If End Sub




Reply With Quote