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 - Help with VB | |
Add to favorites | "RSS" Feed | Next newer thread | Next older thread
User Post
windwaker

Ball and Chain Trooper
WHY ALL THE MAYONNAISE HATE
Level: 61

Posts: 6/1797
EXP: 1860597
For next: 15999

Since: 03-15-04

Since last post: 4 days
Last activity: 6 days
Posted on 03-16-04 10:29 PM Link | Quote
I am really new to VB and I am really learning to edit bytes right now. Plus I have a question: how do I edit, or say add 1 to each byte in a range or the entire file?
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: 39/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-16-04 10:44 PM Link | Quote
Well it kinda depends. Do you copy the entire file to memory first, or just edit it directly?

I assume you're editing the file directly, so you'd do something like this...


Dim nFileNum as Integer, I as Long, Temp as Byte

nFileNum = FreeFile
Open "C:\Test.bin" For Binary As #nFileNum 'You can substitute a String variable for the filename
For I = 5 To 10
Get #nFileNum, I, Temp
Temp = Temp + 1
Put #nFileNum, I, Temp
Next I 'This will loop through the last 3 lines 6 times, with I being 5, 6, 7, 8, 9 and 10
Close #nFileNum


That'll add one to bytes 5 through 10 in the file. (Keep in mind that in VB addresses start at 1 instead of 0 like in most other things, so you'll have to add 1 to any addresses you want.)
windwaker

Ball and Chain Trooper
WHY ALL THE MAYONNAISE HATE
Level: 61

Posts: 7/1797
EXP: 1860597
For next: 15999

Since: 03-15-04

Since last post: 4 days
Last activity: 6 days
Posted on 03-17-04 02:54 AM Link | Quote
Thanks a bunch! I am trying to make an encryption program and this will help a lot! Let's say I open a 10 byte file and say to edit bytes 1 through 15. Would this work?
Mega-Dog

Level: 20

Posts: 25/139
EXP: 40051
For next: 2388

Since: 03-15-04
From: Minnesota

Since last post: 8 days
Last activity: 4 days
Posted on 03-17-04 04:31 AM Link | Quote
my way would be

Option Explicit

DIM fCont() as Byte

open "" for binary as #1
redim fCont(lof(1))
get #1,,fCont
close #1

this will load allt he bytes up in a array called fCont().
FrenziedPanda89

Micro-Goomba
Level: 8

Posts: 4/19
EXP: 2022
For next: 165

Since: 03-16-04
From: Canada

Since last post: 553 days
Last activity: 339 days
Posted on 03-18-04 04:30 AM Link | Quote
I like this site. Enjoy
http://www.garybeene.com/vb/tut-lang.htm
Add to favorites | "RSS" Feed | Next newer thread | Next older thread
Acmlm's Board - I2 Archive - Programming - Help with VB | |


ABII


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



Page rendered in 0.005 seconds.