Results 1 to 4 of 4

Thread: More then one line of text

  1. #1

    Thread Starter
    New Member
    Join Date
    Feb 2004
    Location
    Manchester England
    Posts
    12

    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

  2. #2
    Fanatic Member Dungeon Keeper's Avatar
    Join Date
    Mar 2008
    Posts
    590

    Re: More then one line of text

    Quote 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.

  3. #3

    Thread Starter
    New Member
    Join Date
    Feb 2004
    Location
    Manchester England
    Posts
    12

    Re: More then one line of text

    Quote 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.

  4. #4
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: More then one line of text

    try like
    vb Code:
    1. Open "I:\VB6\Disc1.txt" For Input As #1
    2. inputarr = split(input(lof(1), #1), vbnewline)
    3. Close #1
    4. for i = 0 to ubound(inputarr)
    5.   linearr= split(inputarr(i), ",", 2)
    6.   list1.additem linearr(0)
    7.   text1 = text1 & vbnewline & linearr(1) ' do something with rest of list
    8. 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
  •  



Click Here to Expand Forum to Full Width