|
-
Nov 21st, 2000, 12:53 AM
#1
Thread Starter
Fanatic Member
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....
-
Nov 21st, 2000, 01:53 AM
#2
Open the file in binary mode and dump the length into a byte array. Nice and quick to search that way
- gaffa
-
Nov 21st, 2000, 02:13 AM
#3
transcendental analytic
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.
-
Nov 21st, 2000, 03:19 AM
#4
Thread Starter
Fanatic Member
Can you provide a simple code please...
thank you.
-
Nov 21st, 2000, 03:40 AM
#5
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|