Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Visual Basic > VB 2008 > Visual Basic 2008 Essentials
Password Reminder
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Visual Basic 2008 Essentials If you are new to Visual Basic programming with version 2008, this is the place to start your questions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Visual Basic 2008 Essentials section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Display Modes
  #1 (permalink)  
Old February 17th, 2008, 05:50 PM
Registered User
Join Date: Feb 2008
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default A complex file parser

I need help building a program in VB 2008. Basically, I want to point it at a Binary file, and then have it take the binary, and do the following with it:

1. Take a pair of bits from the beginning of the file
2. Consider the bits, and do the following:
--If they are 00 or 11, toss both of them from the file.
--If the are 01 or 10, keep the first bit, and toss the second one from the file.
3. Move on to the next 2 bits. Repeat.

It needs to do this to the entire file. I plan to simply type in the file location (Like c:\documents and settings\my user name\my documents\randump\dump1.bin) into a text box. It is named "find". The parse will be started by a button named "parse".

There are just possible problems:
1. There is a big chance that the amount of bits removed won't be divisible by 8. This will create an uneven byte at the end. Does the computer care, or should I be worried?
2. When the binary files are opened in notepad, they look like characters. The program needs to see the bits, not characters.

I'm a VB noob, so can somebody show me how one is to do this?

And if you need any more information about the form setup, please ask.

Thanks in advance,


Reply With Quote
  #2 (permalink)  
Old February 17th, 2008, 05:54 PM
Registered User
Join Date: Feb 2008
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts

BTW, I am not in any classes. This is, therefor, not homework. Everything I know about VB I learned from trial and error... and a book that came with the software.

Reply With Quote
  #3 (permalink)  
Old February 19th, 2008, 01:50 PM
Friend of Wrox
Join Date: Nov 2004
Location: Port Orchard, WA, USA.
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts

Files are not organized in bits, but in bytes.  The smallest unit you can retrieve from a file, or put into a file, is a byte.

With that said, prehaps the thing to do—if you are absolutely wedded to this bit-centric approach—is to open an input file and a separate output file. Get a byte from the input file, start parsing til you reach the end of the byte.  While parsing, concatenate, or build, your results using a variable.  When you have a full 8 bits in your variable, write the byte to your output file.  If your tallying takes you across a byte boundary, fill in the last bit of the byte, write it, and continue with this tally event by filling in the 1st bit of the next byte.

Odd task;  why do you want to do this, out of curiosity.
Reply With Quote

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to deal with complex conditions in XSL file? Mateo1041 XSLT 10 October 9th, 2008 11:34 AM
How to upload complex xml file to 1 db table vangogh XML 3 October 8th, 2007 04:43 AM
Importing a Complex Excel file paige BOOK: Professional SQL Server 2005 Integration Services ISBN: 0-7645-8435-9 0 February 7th, 2007 02:22 PM
Parser Error ashokparchuri General .NET 0 June 3rd, 2005 03:14 AM
XML File not found error from xerces parser P.J.Kim XML 0 October 19th, 2004 05:39 AM

All times are GMT -4. The time now is 11:43 AM.

Powered by vBulletin®
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.