Results 1 to 5 of 5

Thread: Summoning All the GURUS

  1. #1

    Thread Starter
    Fanatic Member VBKNIGHT's Avatar
    Join Date
    Oct 2000
    Location
    Port25
    Posts
    619

    Unhappy


    How can i read text file the fastest way in VB6?
    Instead of reading it per line.
    for example i would like to search a certain word like "The". would it be possible? Just like using perl or any text manipulating language.

    Can u help me on this? please....

  2. #2
    Guest
    Open the file in binary mode and dump the length into a byte array. Nice and quick to search that way

    - gaffa

  3. #3
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Any fast ways to search a byte array gaffa? Instr should do the work faster than any code in vb, so why not reading it into a string instead?
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  4. #4

    Thread Starter
    Fanatic Member VBKNIGHT's Avatar
    Join Date
    Oct 2000
    Location
    Port25
    Posts
    619

    Can you provide a simple code please...

    thank you.

  5. #5
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649
    Code:
    Dim iFile As Integer
    Dim sText As String
    Dim iPos As Integer
    
    'read the file
    iFile = FreeFile
    Open "C:\ThePath\TheFile.txt" For Input As iFile
    sText = Input(LOF(iFile), iFile)
    Close iFile
    'search the file
    iPos = Instr(1, sText, "TheTextToSearchFor", vbTextCompare)
    If iPos > 0 Then
        MsgBox "The text was found at position: " & iPos
    Else
        MsgBox "The text was not found"
    End If

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