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
  
User name:
Password:
Reply:
 

UserPost
FrenziedPanda89
Posts: 4/19
I like this site. Enjoy
http://www.garybeene.com/vb/tut-lang.htm
Mega-Dog
Posts: 25/139
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().
windwaker
Posts: 7/1797
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?
HyperLamer
Posts: 39/8210
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
Posts: 6/1797
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?
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.010 seconds.