CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Nov 2000
    Location
    Norway
    Posts
    46

    Remove ascii 00 in files

    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

  2. #2
    Join Date
    Apr 2000
    Posts
    737

    Re: Remove ascii 00 in files

    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.




  3. #3
    Join Date
    Mar 2001
    Posts
    7

    Re: Remove ascii 00 in files

    You can use REPLACE function too.

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



  4. #4
    Join Date
    Jul 2000
    Location
    Milano, Italy
    Posts
    7,726

    Re: Remove ascii 00 in files

    Excelent! (I am out of vote for today)

    Special thanks to Lothar "the Great" Haensler. Come back soon, you Guru.
    ...at present time, using mainly Net 4.0, Vs 2010



    Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
    all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured