What is the fastest way of reading text file?
if for example i will search a word "The" in a paragraph using vb6.
Printable View
What is the fastest way of reading text file?
if for example i will search a word "The" in a paragraph using vb6.
temp will return the number of occurences of your search$ in your original$ (textfile)Code:temp = InStr(1, "Original$", "Search$")
Oops, no it won't Hollie. InStr returns the position of the first occurence of the string.
Cheers,
P.
sorry!
:(
H.
Hollie...it's good practice to test before you post.
:D
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
thanks for all your help...
Anybody who could suggest superfast text reading? how about u kedaman?