Click to See Complete Forum and Search --> : Remove ascii 00 in files


Thorvald
March 29th, 2001, 05:07 AM
hi,

I have some files containing the ascii value 00, (even if it isn't an ascii value). I want to write an VB app to replace this with character space.

Any suggestions,
Thans in advance

ThoRvalZ

cksiow
March 29th, 2001, 06:12 AM
you got to open the file and read the whole content of the file into a string (try http://vblib.virtualave.net, there is a function in vbFileIO which able to do so).

Let say, you got the string already call s. then

do the following

for i = 1 to len(s)
if mid(s,i,1) = chr(0) then
mid(s,i,1) = chr(32)
end if
next i

after this, the string should no longer contain any 0 but space instead.

so, you need to write the string back to a file, again , there is another function which able to do so also

hope this help.

Timothy
March 29th, 2001, 06:26 AM
You can use REPLACE function too.

myString = replace(myString,chr(0),chr(32))

Cimperiali
March 29th, 2001, 09:09 AM
Excelent! (I am out of vote for today)

Special thanks to Lothar "the Great" Haensler. Come back soon, you Guru.