-
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....
-
Open the file in binary mode and dump the length into a byte array. Nice and quick to search that way
- gaffa
-
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?
-
Can you provide a simple code please...
thank you.
-
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