G'Day
I started looking at what you meant by "determining" why the text file
ends
up on one line. Inside the text file, the entire list ends up enclosed
inside quotation marks:
i.e.
"DO NOT WRITE ON THIS LINE!
12R-DJDS-4045T
4HT-DDS-4-2011
"
The above example shows how the quotation marks end up inside the text
file.
This is the script to "write to the text file";
Private Sub WriteMe_Click()
Dim MyData As String
Dim i As Integer
For i = 0 To ListBox.ListCount - 1
MyData = MyData & ListBox.List(i) & vbCrLf
Next i
Open "p:\help files\prod\text.txt" For Output As #1
Write #1, MyData
Close #1
Close
End Sub
The list box is populated from the text file by:
Private Sub Form_Load()
entrydate.text = "[ " & Date & " ]"
Dim i As Long, strText As String, flnStream As String
flnStream = "P:\Help Files\Prod\Text.txt"
i = FreeFile
Open flnStream For Input As #i
Do While Not EOF(1)
Input #1, strText
ListBox.AddItem (strText)
Loop
Close #i
Close
End Sub
The listbox shows black lines between the listed text, and the text shows
up
on one line, example
DO NOT WRITE ON THIS LINE! || 12R-DJDS-4045T || 4HT-DDS-4-2011||
If I edit the text file, and remove the quotation marks, or move the end
quotation mark to the end of the first line "DO NOT WRITE ON THIS LINE!",
then the listbox will be correct, and look just like the text file, until
the
next time I write to the file.
I use this to remove line items inside the list box, before I write to it:
Private Sub RemoveItem1_Click()
On Error Resume Next 'in case the user forgets to select a line
to
be removed
If ListBox.ListCount >= 1 Then
ListBox.RemoveItem (ListBox.ListIndex)
End If
End Sub
And this is to add to the text file: '(the text is written inside a text
box
on the form)
Private Sub add_Click()
Open "p:\help files\prod\text.txt" For Append As #1
Print #1, entrydate
Print #1, text
ListBox.AddItem text
Close #1
Close
End Sub
While this seems like a lot to ask, I do not understand where the
quotation
marks come from inside the text box, if I edit them out, and write to the
file using the "Write_Me" sub, the quotation marks come back.
Tanx
Krakmup
Karl E. Peterson said:
How are you determining that?