Results 1 to 9 of 9

Thread: Import data from text file

  1. #1

    Thread Starter
    Lively Member
    Join Date
    May 2001
    Location
    n/a
    Posts
    89

    Import data from text file

    I am reading data from a text file into a text box. When the data comes up it reads a b c d e f g (with a CarriageReturn symbol between each letter) In the text file the letters are on different lines. Any help would be great.
    n/a

  2. #2
    Addicted Member
    Join Date
    Aug 2001
    Location
    Munic
    Posts
    178

    Make your own Filter

    If you don't want to ahve CRLF in your string you have to look for

    Chr(13) & Chr(10)

    and make a Filter

    CU
    Kreuzfeld

  3. #3

    Thread Starter
    Lively Member
    Join Date
    May 2001
    Location
    n/a
    Posts
    89
    ?
    n/a

  4. #4

    Thread Starter
    Lively Member
    Join Date
    May 2001
    Location
    n/a
    Posts
    89
    It's not that I dont want the CRLF. I want the action of CRLF not the CRLF character.
    n/a

  5. #5
    Addicted Member
    Join Date
    Aug 2001
    Location
    Munic
    Posts
    178

    like this

    for i=1 to StringLength do

    if (string(i) <> Chr(13)) OR (string(i) <> Chr(10)) then
    NewString = NewString & string(i)
    end if

    next i


    try this
    maybe it works :-)

  6. #6
    Fanatic Member
    Join Date
    Oct 2000
    Location
    Reading, UK
    Posts
    870
    dim s as string

    open filename "c:\temp.txt" for input as #1

    do until EOF(1)
    input #1, s
    textbox = textbox & s
    loop

    close #1


    i think this is what you are asking for.
    you might need to add microsoft scripting runtime as a refernce as well.

    Nick

  7. #7

    Thread Starter
    Lively Member
    Join Date
    May 2001
    Location
    n/a
    Posts
    89
    I tried this, but it still returning the CrLf symbol and not performing the CrLf action.

    Code:
    Dim s As String
    Dim fn As Integer
    fn = FreeFile
    
    Open strName For Input As #fn
    
    Do Until EOF(1)
    
    txtContents = Input(LOF(fn), #fn) & s
    Loop
    
    Close #fn
    n/a

  8. #8
    Fanatic Member
    Join Date
    Oct 2000
    Location
    Reading, UK
    Posts
    870
    have you got the text box set to multiline?

    if so, just check all the chars in the string for vbcrlf. If you find one, replace it with a space, and start a new line in the textbox.

    Nick

  9. #9

    Thread Starter
    Lively Member
    Join Date
    May 2001
    Location
    n/a
    Posts
    89
    MultiLine, why didn't I think of that. This has been killing me. Thanks, that was it. The easy answer.
    n/a

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