Results 1 to 6 of 6

Thread: Reading Text file

  1. #1

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

    Question


    What is the fastest way of reading text file?
    if for example i will search a word "The" in a paragraph using vb6.




  2. #2
    Lively Member
    Join Date
    Oct 2000
    Location
    Scotland
    Posts
    96
    Code:
    temp = InStr(1, "Original$", "Search$")
    temp will return the number of occurences of your search$ in your original$ (textfile)

    Just trying to muddle through...

  3. #3
    Fanatic Member
    Join Date
    Oct 2000
    Location
    London
    Posts
    1,008
    Oops, no it won't Hollie. InStr returns the position of the first occurence of the string.

    Cheers,

    P.
    Not nearly so tired now...

    Haven't been around much so be gentle...

  4. #4
    Lively Member
    Join Date
    Oct 2000
    Location
    Scotland
    Posts
    96
    sorry!


    H.
    Just trying to muddle through...

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

    <?>

    Hollie...it's good practice to test before you post.

    Everyone makes errors, so don't sweat it.

    'not tested for speed but it gets the job done
    Code:
    Option Explicit
    'remove option compare text if you want the seach to be case aware
    Option Compare Text
    
    'contents of file
    'I was drinking tea in the beverage room of the house
    
    Private Sub Command1_Click()
    
        Dim sfile As String, intNum As Integer, myString As String
        intNum = FreeFile
        sfile = "C:\my Documents\myfile.txt"
        
        Open sfile For Input As intNum
           myString = StrConv(InputB(LOF(intNum), intNum), vbUnicode)
         Close intNum
         
       Dim myFind As String, myLen As String, iCount As Integer
       Dim mySearch As String
       
       mySearch = "the"
       For iCount = 1 To Len(myString)
          myLen = InStr(1, myString, mySearch)
        Next
    'the balance of the file including "the first the"
        myString = Right(myString, Len(myString) - (CInt(myLen) - 1))
        MsgBox myString
        
        
    End Sub
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  6. #6

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

    Smile

    thanks for all your help...

    Anybody who could suggest superfast text reading? how about u kedaman?

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