Results 1 to 11 of 11

Thread: reading complete lines from a string

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Dec 2001
    Location
    Guess....i have wooden shoes, in my free time i sell tulips and I live in a huge windmill...
    Posts
    176

    reading complete lines from a string

    I opened a text file, loaded it into a string and now i want to read it line by line. How do i make this?

    thnx

  2. #2
    Addicted Member
    Join Date
    Feb 2002
    Location
    United
    Posts
    202
    Open STRFILENAME For Input As #1
    Do While Not EOF(1)
    Input #1, line
    debug.print line
    Loop
    Close #1

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Dec 2001
    Location
    Guess....i have wooden shoes, in my free time i sell tulips and I live in a huge windmill...
    Posts
    176
    can't i make this a loop? i'm using .net so i don't use the input thing.

  4. #4
    PowerPoster
    Join Date
    Jun 2001
    Location
    Trafalgar, IN
    Posts
    4,141
    Don't know why you would want to do it this way but you could use the split function to get each line and then loop through the array that is created.

  5. #5
    Addicted Member
    Join Date
    Feb 2002
    Location
    United
    Posts
    202
    <code>can't i make this a loop? i'm using .net so i don't use the input thing
    </code>
    can't i make this a loop ?
    din realli get the questions .


    i'm using .net so i don't use the input thing
    sorry , i do not know any anithing about .net, i m using vb 6. sorri for tat .

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Dec 2001
    Location
    Guess....i have wooden shoes, in my free time i sell tulips and I live in a huge windmill...
    Posts
    176
    sorry,

    i was thinking about a loop that reads through a string untill it sees an enter. I don't know how to see the enter. the rest is quite easy. Do u know of another way to do this without the line statement?

  7. #7
    Addicted Member
    Join Date
    Feb 2002
    Location
    United
    Posts
    202
    '''''''''''''''''''''''''''''''''''''''
    ' Dim arr() As String
    ' Dim i As Integer
    '
    '
    '
    '
    ' Open App.Path & "this.txt" For Input As #1
    ' arr = Split(Input(LOF(1), 1), vbCr)
    '
    ' Close #1
    '
    ' For i = 0 To UBound(arr)
    '' Debug.Print arr(i)
    ' MsgBox arr(i)
    ' Next i
    '' ''''''''''''''''''''''''''''''''''''''

    Anyway i use the do while not EOF , cos i think it is much simpler n din tok of the split() cos i hardly use it .., thaxs for pointing out

  8. #8

    Thread Starter
    Addicted Member
    Join Date
    Dec 2001
    Location
    Guess....i have wooden shoes, in my free time i sell tulips and I live in a huge windmill...
    Posts
    176
    thnx, i changed it a bit and now it works, do u also know a way to split up a string like this

    Hello=hallo

    into

    knownword = hallo
    unknownword = hello

    Thnx

  9. #9
    Addicted Member
    Join Date
    Feb 2002
    Location
    United
    Posts
    202
    Hello=hallo

    into

    knownword = hallo
    unknownword = hello

    Thnx

    u wan to change onli 1 letter in the sentence rite ?
    if u are trying to change a letter u can use the Mid$() ?


    unknownword=mid$(knownword,2,1)

  10. #10

    Thread Starter
    Addicted Member
    Join Date
    Dec 2001
    Location
    Guess....i have wooden shoes, in my free time i sell tulips and I live in a huge windmill...
    Posts
    176
    ahhhh no not at all :-)

    the 2nd line looks like this:

    hallo=hello

    how do i split this line up in hello and hallo?

  11. #11
    Addicted Member
    Join Date
    Feb 2002
    Location
    United
    Posts
    202
    http://www.vbforums.com/showthread.p...ighlight=split

    i think this thread might have wat u need...

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