Bill_H
April 4th, 2001, 03:11 PM
Why does a list box "wrap" to a new line or create a new field when it encounters a comma in the following code? ...The commas only cause a "wrap" after a string containing a comma is retrieved from disk and added to List2...
'1 form, 2 list boxes, 2 command buttons
Private Sub Command1_Click()
List1.AddItem "A line with a , comma."
Call SaveData(List1, App.Path & "\ListData.dat")
End Sub
Private Sub Command2_Click()
Call GetData(List2, App.Path & "\ListData.dat")
End Sub
Public Sub SaveData(TheList As ListBox, MyString As String)
Dim SaveList As Long
Open MyString$ For Output Shared As #1
For SaveList& = 0 To TheList.ListCount - 1
Print #1, TheList.List(SaveList&)
Next SaveList&
Close #1
End Sub
Public Sub GetData(TheList2 As ListBox, MyString2 As String)
Dim Item As String
Open MyString2$ For Input Shared As #1
While Not EOF(1)
Input #1, Item$
DoEvents
TheList2.AddItem Item$
Wend
Close #1
End Sub
'1 form, 2 list boxes, 2 command buttons
Private Sub Command1_Click()
List1.AddItem "A line with a , comma."
Call SaveData(List1, App.Path & "\ListData.dat")
End Sub
Private Sub Command2_Click()
Call GetData(List2, App.Path & "\ListData.dat")
End Sub
Public Sub SaveData(TheList As ListBox, MyString As String)
Dim SaveList As Long
Open MyString$ For Output Shared As #1
For SaveList& = 0 To TheList.ListCount - 1
Print #1, TheList.List(SaveList&)
Next SaveList&
Close #1
End Sub
Public Sub GetData(TheList2 As ListBox, MyString2 As String)
Dim Item As String
Open MyString2$ For Input Shared As #1
While Not EOF(1)
Input #1, Item$
DoEvents
TheList2.AddItem Item$
Wend
Close #1
End Sub