Register | Login
Views: 19364387
Main | Memberlist | Active users | ACS | Commons | Calendar | Online users
Ranks | FAQ | Color Chart | Photo album | IRC Chat
11-02-05 12:59 PM
0 user currently in Programming. | 3 guests
Acmlm's Board - I2 Archive - Programming - Deleting bytes with VB6 | |
Add to favorites | "RSS" Feed | Next newer thread | Next older thread
User Post
Chickenlump

Level: 41

Posts: 48/722
EXP: 474192
For next: 5953

Since: 03-15-04
From: Columbia City Indiana

Since last post: 3 hours
Last activity: 4 min.
Posted on 03-22-04 10:32 PM Link | Quote
I am curious if it's possible to delete bytes from a file with Visual Basic 6.
I was hoping someone here could help me.
I was just going to code a small tool for myself to delete the snes header off of the Rom, which I belive is the first 200 bytes.
Someone mentioned that I could start reading the file from that offset, and dump to another file, and just rename it, but I'm not sure how to go about that just yet. Or, if there's an easier way that would be cool too.
I know there's tools already available to delete the header, but I wouldn't learn anything in the process, and it would be more convinent to just have it built in to my little app.

Thanks for any replies.
Darth Coby

Vire
Dacht je nou echt dat het over was?
Dacht je nou echt dat ik gebroken was? Nee toch?
Nou kijk eens goed op uit je ogen gast.
zonder clic heb je geen kloten tjap... bitch
Level: 55

Posts: 129/1371
EXP: 1240774
For next: 73415

Since: 03-15-04
From: Belgium

Since last post: 2 days
Last activity: 9 hours
Posted on 03-23-04 02:02 AM Link | Quote
Load it as binary, then start reading from byte number $200. Then dump it to another file and replace, that should work. Just like you said.
I don't know how you'd start reading from byte number $200 though.
HyperLamer
<||bass> and this was the soloution i thought of that was guarinteed to piss off the greatest amount of people

Sesshomaru
Tamaranian

Level: 118

Posts: 142/8210
EXP: 18171887
For next: 211027

Since: 03-15-04
From: Canada, w00t!
LOL FAD

Since last post: 2 hours
Last activity: 2 hours
Posted on 03-23-04 05:47 AM Link | Quote
Dim i as Long, nFileNum as Integer, FileNum2 as Integer
Dim TempByte as Byte
nFileNum = FreeFile
Open "C:\Somefile" for Binary as #nFileNum
FileNum2 = FreeFile
Open "C:\OutputFile" for Binary as #FileNum2
For i = &h200 to LOF(nFileNum)
Get #nFileNum, i, TempByte
Put #FileNum2, i-&h200, TempByte
DoEvents 'So it doesn't crash
Next i
Close #nFileNum
Close #FileNum2
Kenny3900
Newcomer
Level: 6

Posts: 6/9
EXP: 659
For next: 248

Since: 03-15-04

Since last post: 576 days
Last activity: 339 days
Posted on 03-23-04 12:12 PM Link | Quote
I'd rather do it like this:

...
Dim Temp() as Byte
...
Redim Temp(LOF(nFileNum) - 512) ' 512 = &H200
...
Get nFileNum, 513, Temp 'File pointer starts at 1.
Put nFileNum2, 1, Temp
...
HyperLamer
<||bass> and this was the soloution i thought of that was guarinteed to piss off the greatest amount of people

Sesshomaru
Tamaranian

Level: 118

Posts: 147/8210
EXP: 18171887
For next: 211027

Since: 03-15-04
From: Canada, w00t!
LOL FAD

Since last post: 2 hours
Last activity: 2 hours
Posted on 03-24-04 02:45 AM Link | Quote
You can do that? Seeing how you can't assign to an array, that's quite surprising.
Chickenlump

Level: 41

Posts: 53/722
EXP: 474192
For next: 5953

Since: 03-15-04
From: Columbia City Indiana

Since last post: 3 hours
Last activity: 4 min.
Posted on 03-24-04 03:02 AM Link | Quote
Thank you both so much!
All this is very interesting.
Since I'm in a learning mood lately, I'll be pesky and ask...
What do you mean by "Cant's assign to an array"?



Kenny3900
Newcomer
Level: 6

Posts: 7/9
EXP: 659
For next: 248

Since: 03-15-04

Since last post: 576 days
Last activity: 339 days
Posted on 03-24-04 12:40 PM Link | Quote
Originally posted by HyperHacker
You can do that? Seeing how you can't assign to an array, that's quite surprising.


Which VB version you use? It ran correctly for me. I haven't go in depth of the program, but I tried the get/put part and there's no error. I'm using VB6.
Add to favorites | "RSS" Feed | Next newer thread | Next older thread
Acmlm's Board - I2 Archive - Programming - Deleting bytes with VB6 | |


ABII


AcmlmBoard vl.ol (11-01-05)
© 2000-2005 Acmlm, Emuz, et al



Page rendered in 0.005 seconds.