|
-
Apr 18th, 2008, 04:06 AM
#1
Thread Starter
New Member
More then one line of text
i have a text file with disc name and what is on the disc, but sometimes there is five or six items on a disc and some time there will be only one.
i.e.
Disc 1,Game 1,Game 2,Game 3
Disc 2,Game 4,Game 5
Disc 3,Game 6,Game 7,Game 8,Game 9,Game 10,Game 11
on so on...
i have load the text in and printed it out to a listbox, but it just prints all the contents, here is the code
Code:
Private Sub Form_Load()
Dim DiscName As String
Dim ContentsofDisc As String
Dim num As Integer
Open "I:\VB6\Disc1.txt" For Input As #1
Input #1, DiscName, ContentofDisc
List1.AddItem DiscName
Close #1
End Sub
I want the disc list of the text file in the listbox and the game list to be printed on another part of the form.
Can anybody help me with this please
-
Apr 18th, 2008, 04:10 AM
#2
Fanatic Member
Re: More then one line of text
 Originally Posted by Champions_2002
i have a text file with disc name and what is on the disc, but sometimes there is five or six items on a disc and some time there will be only one.
i.e.
Disc 1,Game 1,Game 2,Game 3
Disc 2,Game 4,Game 5
Disc 3,Game 6,Game 7,Game 8,Game 9,Game 10,Game 11
on so on...
i have load the text in and printed it out to a listbox, but it just prints all the contents, here is the code
Code:
Private Sub Form_Load()
Dim DiscName As String
Dim ContentsofDisc As String
Dim num As Integer
Open "I:\VB6\Disc1.txt" For Input As #1
Input #1, DiscName, ContentofDisc
List1.AddItem DiscName
Close #1
End Sub
I want the disc list of the text file in the listbox and the game list to be printed on another part of the form.
Can anybody help me with this please
Why dont you use IF.
If ucase$(left$(a$,4)) = "DISC" then list1.additem
else: text1.text = a$
or something simmilar
Last edited by Dungeon Keeper; Apr 18th, 2008 at 04:21 AM.
-
Apr 18th, 2008, 04:13 AM
#3
Thread Starter
New Member
Re: More then one line of text
 Originally Posted by Dungeon Keeper
Why dont you use IF. If ucase$(left$(a$,4)) = "DISC" then list1.additem
there are over 2000 disc, so doing that way will take an age.
-
Apr 18th, 2008, 04:41 AM
#4
Re: More then one line of text
try like
vb Code:
Open "I:\VB6\Disc1.txt" For Input As #1 inputarr = split(input(lof(1), #1), vbnewline) Close #1 for i = 0 to ubound(inputarr) linearr= split(inputarr(i), ",", 2) list1.additem linearr(0) text1 = text1 & vbnewline & linearr(1) ' do something with rest of list next
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
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
|