|
-
April 4th, 2001, 03:11 PM
#1
Commas and List box
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
-
April 4th, 2001, 03:58 PM
#2
Re: Commas and List box
In sub GetData, change your "Input" statement to "Line Input".
the comma in the input stream is a Basic function delimiting a end of token.
John G
-
April 4th, 2001, 04:12 PM
#3
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
|