|
-
Jul 9th, 2004, 03:08 AM
#1
Thread Starter
New Member
Problem while outputting to a textfile
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
-
Jul 9th, 2004, 03:27 AM
#2
Hyperactive Member
Lil fixes 
VB Code:
Dim strFilename As String
Dim intMessage As Integer
Dim i As Integer
If lst.List(0) <> "" Then
strFilename = InputBox("Input filename for new output textfile", "Input Filename")
strFilename = strFilename & ".txt"
Open "C:\" & strFilename For Output As #1 '- Change path to whatever you want
For i = 0 To lst.ListCount - 1 '- Get all listbox contents...
Print #1, lst.List(i)
Next i
Close #1
MsgBox ("Textfile has been created")
Else
MsgBox ("There are no output values to output to file")
End If
Born to help others
(If I've been helpful then please rate my post. Thanks)
call me EJ or be slapped! 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|