Flat text File Read in Dilemma!

I have a file I need to read in. Easy right Here’s the catch. Its 17k+ records than all end in a vbLF.  If they ended in vbCRLF the following would work but they Don’t so its not.

Current Code:

 StrPathToFile = "Filename"

OpenReadFile

 Do

        ReadFile

        DoWhatNeedsToBeDoneHere

Loop While Not EOF(#ntFileNum)

 

Inputs used:

Public Sub OpenReadFile()

intFileNum = FreeFile

Open strPathToFileIn For Input As #intFileNum

End Sub

 

Public Sub ReadFile()

Line Input #intFileNum, strCHRecord

End Sub

 

It takes in the Whole file as one string and gets about 5mil of the characters instead of the 30mil in the file.

Is there a Different “input” I should be using Any thoughts on this one




Answer this question

Flat text File Read in Dilemma!

  • Hassan Ayoub

    I have VB express but given id have to try and figure out the entire program in .NET and I dont have that kind of time.

    Deadlines Suck



  • knuckle05

    OR you could convert the project to VB2005. If it's well written that shouldn't take long.... to get it up to speed.



  • divya mittal

    How about reading the entire file

    My.Computer.Filesystem.ReadAllText method

    and then splitting the file into a series of lines based upon the VBLF using

    Something like

    Dim s As String = ""

    Dim c() As Char = {vbLf}

    Dim sa() As String = s.Split(c, StringSplitOptions.None)

    Then you can process each line individually from the Sa array of strings


  • roy_b

    So if your asking the question about .net (VB Express , VB.NET) the solutions above will work - if your asking about VB6 then this is not the right place.


  • ReneeC

    You should have read the description of what the these forums are about "Not VB6"

    What your asking for is completely possible but these forums are for VB.NET and there are better places to find answers for older versions of VB such as VB6.

    Maybe the VB6 newgroups - http://msdn.microsoft.com/newsgroups/default.aspx dg=microsoft.public.vb.general.discussion&lang=en&cr=US

    or the VB6 resource center
    http://msdn.microsoft.com/vbrun/

    or web sites such as www.vbcity.com

    You could however download VB Express and start working with .NET technology - its free to download from microsoft web site.

    Hope these point you in the right direction.


  • Billr17

    That would be the .NET solution

    Im sorry i shouldve clarified. vb 6.0



  • MatrixResolver

    Well said Renee, then you can ask all the questions you want as the project would be .NET and therefore it would be appropriate for these forums.


  • Flat text File Read in Dilemma!