how can I write arbitrary 1s an 0s directly into a file?

TiagoTiago
06-06-2003, 12:01 PM
is it possible?
or is there a way to convert a string with the lenght of eight characters into a byte?( the characters are 0s and 1s)
btw, is the format for ima cd image files just a any file with .ima in the end? I read somewhere that those files are just coposed just by the exact bits that are in the cd... and nothing else... is that right? need to write a cd with arbitrary 0s and 1s... it won't contain any data , or boot info... just the 0s and 1s I put in it... is that possible?
thanx

Squirm
06-06-2003, 06:08 PM
You'd need to create your own conversion routine. Something like this (off the top of my head):

Private Function StrToByte(sBinary As String) As Byte
Dim iBit As Long
Dim iExp As Long
Dim iResult As Long

iExp = 128
For iBit = 0 To 8
iResult = iResult Or ((Asc(Mid$(sBinary, iBit, 1)) - 48) * iExp)
iExp = iExp \ 2
Next iBit

StrToByte = CByte(iResult)
End Function

Of course this is very rough and lacks any error handling.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum