|
-
Mar 19th, 2000, 01:06 AM
#1
Thread Starter
New Member
I'm making a program that will search if text1.text is in a file. and if it is it will print it in a textbox called textbox. Please help me and I would appreciate it if it was detailed.
-
Mar 19th, 2000, 07:20 PM
#2
Frenzied Member
here's one way:
Code:
Private Sub Command1_Click()
TextBox.Text = SearchFile(filename, Text1.Text)
End Sub
Private Function SearchFile(filename As String, SearchText As String) As String
Dim fnum As Byte
Dim strTemp As String
fnum = FreeFile
Open filename For Binary As fnum
strTemp Space(LOF(nfum))
Get #fnum, , strTemp
Close fnum
If InStr(strTemp, SearchText) > 0 Then
SearchFile = strTemp
End If
End Function
-
Mar 27th, 2000, 04:44 PM
#3
Lively Member
Hi,
I have a similar problemm, except that I need to search in a file that could be 50Mb. Does anybody have a nice fast way of doing this rather than creating a 50Mb string !
cheers
Andy
-
Mar 27th, 2000, 06:15 PM
#4
transcendental analytic
Try to get parts of it, not the whole file.
-
Mar 27th, 2000, 06:37 PM
#5
Lively Member
Hi,
Thanks for the info. I'd started down the wrong track in loading the data as a byte array. I've switched to a binary read with a reasonable size string (64K) and using Instr to find the locations and it now works very well.
thanks for the info
cheers
Andy
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
|