|
-
Nov 20th, 2000, 09:12 PM
#1
Thread Starter
Fanatic Member
What is the fastest way of reading text file?
if for example i will search a word "The" in a paragraph using vb6.
-
Nov 21st, 2000, 04:47 AM
#2
Lively Member
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...
-
Nov 21st, 2000, 09:26 AM
#3
Fanatic Member
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...
-
Nov 21st, 2000, 09:35 AM
#4
Lively Member
sorry!

H.
 Just trying to muddle through...
-
Nov 21st, 2000, 09:54 AM
#5
_______
<?>
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
-
Nov 21st, 2000, 09:25 PM
#6
Thread Starter
Fanatic Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|