|
-
Feb 7th, 2001, 11:29 AM
#1
Thread Starter
PowerPoster
I thought I'd make a quick utility for myself to extract all ASCII "printable" characters from a file, but unfortunately, this code causes my app to hang when I run it. Can you tell me where I went wrong? (BTW, this is just a quickie, don't yell at me for lack of naming conventions and error handling!)
Code:
' in a command button
Dim lnglen As Long
Dim strchar As String * 1
Dim lngX As Long
Dim intFF As Integer
CommonDialog1.ShowOpen
intFF = FreeFile
Open CommonDialog1.filename For Binary Access Read As #intFF
lnglen = LOF(intFF)
For lngX = 1 To lnglen
Get #intFF, lngX, strchar
If Asc(strchar) >= 32 And Asc(strchar) <= 127 Then
Text1.Text = Text1.Text & strchar
End If
Next
Close #intFF
TIA for your help ...
"It's cold gin time again ..."
Check out my website here.
-
Feb 7th, 2001, 11:42 AM
#2
_______
<?>
'try this
'looks like you keep reading the full line over and over
'just a guess..didn't test this
Dim lnglen As Long
Dim strchar As String * 1
Dim lngX As Long
Dim intFF As Integer
CommonDialog1.ShowOpen
intFF = FreeFile
Open CommonDialog1.FileName For Binary Access Read As #intFF
lnglen = LOF(intFF)
For lngX = 1 To lnglen
Get #intFF, lngX, strchar
If Asc(strchar) >= 32 And Asc(strchar) <= 127 Then
Text1.Text = Text1.Text & strchar
End If
strchr = Right(strchr, lnglen - 1)
Next
Close #intFF
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
-
Feb 7th, 2001, 11:43 AM
#3
Hyperactive Member
it would be better to read a chunk of the data into a buffer string and parse in RAM instead of pulling one byte at a time from the file. This way you can read a buffers worth of data, pull out what you need and repeat until you are done with the file.
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
|