|
-
Mar 23rd, 2000, 12:14 AM
#1
Thread Starter
Lively Member
Ok I am writing a program, and it reads binary files, but using vb6's normal file thing 'Open file for Binary as filenum' and the function 'input(1, 1)' well its way too slow. It takes like a whole second to read a 2k file. I need some scripting or API to make it read faster. so see if you can help.
-
Mar 23rd, 2000, 12:32 AM
#2
New Member
Open the file in binary
Get the length of file in bytes
dim avariable that many bytes big
do this:
input(filenumber,'avariable that many bytes big')
instead of this:
input(1,1) 'this inputs one byte at a time! That's Slow 
Now hit the manuals boy! 
[Edited by 23yearsofit on 03-23-2000 at 12:33 PM]
-
Mar 23rd, 2000, 12:34 AM
#3
Hyperactive Member
Read it all in one go into a Byte() array - much faster!
Code:
Dim myData() As Byte
i = FreeFile
Open "C:\Temp\myFile.def" For Binary Access Write As #i
Put #i, , myData
Close #i
Hope that helps

Dan
-
Mar 23rd, 2000, 12:38 AM
#4
Hyperactive Member
Sorry...you should use Get not Put.....
Code:
Dim myData() As Byte
i = FreeFile
Open "C:\Temp\myFile.def" For Binary Access Read As #i
Get #i, , myData
Close #i
You can use FileLen(myFile.def) to find the size of the file if you want and then Dim myData to the right size...

Dan
-
Mar 23rd, 2000, 10:02 AM
#5
Thread Starter
Lively Member
COOL! Ok.
OK cool I got it. Thanx guys!
Don't worry I'll write a sub that takes one off the string every time don't worry I'll get it easily.
You don't know how important this is guys thanx guys.
Wow you guys get a lot of posts I posted this 10 hours ago and its way way down the list...
If you want to see my work just go to http://zap.to/Vuen the botmaker is what I'm working on, if any of you have played OMF2097 well this is to make your own robots for the game. Its about half done thats why its version 0.5 thats released right now see the problem was the image previewer. It was... well slow.
Well nuts. I have a bigger problem now. I have a big geography test tomorrow (grade 9) but my problem is I will stay up all night making this work and then freak out and not be able to sleep and then I will be all screwed for the test.
-
Mar 25th, 2000, 06:24 AM
#6
Fanatic Member
Super fast way to read with binary
I dont know if this is a good way to do this.. but, if u wanna read something into a textbox then just do.
Dim AGET as string * 50000
open myfile for binary as #1
do
get 1,,aget
text1.text = text1.text & aget
loop until eof(1)
close #1
-
Mar 26th, 2000, 03:09 PM
#7
Frenzied Member
invitro,
I dont know if this is a good way to do this..
I would say it's not a particullaly good way
becasuse it's wasting resources and processor time.
(not to mention using a fixed file number )
Code:
Dim strTemp as String
i = FreeFile
Open "C:\Temp\myFile.def" For Binary Access Read As #i
strTemp = space(LOF(i)
Get #i, , strTemp
Close #i
Text1.text = strtemp
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
|