Results 1 to 5 of 5

Thread: HIyas

  1. #1

    Thread Starter
    Addicted Member Skeen's Avatar
    Join Date
    Jul 2000
    Location
    Abingdon, Oxon
    Posts
    138

    Question

    I'm trying to read each line of a text file into an array, I'm using vbCrLf as the delimiter but the whole file is being read into the first elemnt. I'm using the split function but it doesn't seem to like it. Can anyone see where I'm going wrong?

    FileName = Command() + "nng_list.TXT"
    FileNumber = FreeFile

    'Open file and read lines
    Open FileName For Input Access Read As #FileNumber
    Do Until EOF(FileNumber)
    'Assign content to variable
    Line Input #FileNumber, Data

    'Create New File of type *.DAT for use in SQL*Loader.exe
    WriteFile = Command() + "nng_list.DAT"

    WriteFileNumber = FreeFile
    'Open New File for writing to

    Open WriteFile For Append Access Write As #WriteFileNumber
    'Split function to disect data
    Datak = Split(Data, vbCrLf)
    'Datak = Split(Data, "#", -1)
    'Discard unwanted data
    Print #WriteFileNumber, Datak()
    Loop

    Cheers all

    "It wasn't the booze that made me snooze, It was the Gin that did me in!"

  2. #2
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    there is an an example of split and reading a split found Here . Perhaps it will help.
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  3. #3
    Addicted Member
    Join Date
    Oct 2000
    Location
    Vienna/Austria
    Posts
    132
    Hi Skeen !!!

    Your problem is in the split command !!!

    if you use input to open a file the line delimiter is vbcrlf
    in your case u have maybe a file from a unix system.

    Unix systems use as default vbcr or vblf as line delimiter.

    so change the line
    Code:
    Datak = Split(Data, vbCrLf) 
    
    'to
    Datak = Split(Data, vbCr) 
    'or
    Datak = Split(Data, vbLf)
    hope this helps

    -cu TheOnly



  4. #4

    Thread Starter
    Addicted Member Skeen's Avatar
    Join Date
    Jul 2000
    Location
    Abingdon, Oxon
    Posts
    138

    Thumbs up Nice 1 Brother

    Cheers man

    I'm a bit of a unix virgin and integrating NT and Unix is a bit confusing to me at the moment.

    Thanx again
    "It wasn't the booze that made me snooze, It was the Gin that did me in!"

  5. #5

    Thread Starter
    Addicted Member Skeen's Avatar
    Join Date
    Jul 2000
    Location
    Abingdon, Oxon
    Posts
    138

    Talking You Da Man!

    Yeah TheOnly

    You da man - I've been at that for 2 dayz, worked a fookeen charm.

    Cheers m8

    skeen
    "It wasn't the booze that made me snooze, It was the Gin that did me in!"

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