Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > General > comprestion or Bit information please


Reply
 
Thread Tools Display Modes
  #1  
Old 12-17-2001, 03:35 PM
Chazz_56
Guest
 
Posts: n/a
Lightbulb comprestion or Bit information please


I juzz had this idea (2-4 months age) that would revolutionase comprestion. Zipping with a ration inferieur to 5%. What I mainly need is to know how I could read the bit of a file and put it into a variable sush as a string... if you have any information like open sourse DLL or anything that may help me or advise me. (or even programming HELP ) Post it here please.


Thanks allot from a wanna be pro
Reply With Quote
  #2  
Old 12-17-2001, 08:30 PM
karimahta karimahta is offline
Senior Contributor

* Guru *
 
Join Date: Mar 2000
Location: Christchurch, New Zealand
Posts: 470
Default Re: comprestion or Bit information please

This may help you out:

<pre><font color=blue>Private Sub</font color=blue> Command1_Click()
<font color=blue>Dim</font color=blue> hFile <font color=blue>As Long</font color=blue>
<font color=blue>Dim</font color=blue> bytData() <font color=blue>As Byte</font color=blue>
<font color=blue>Dim</font color=blue> strDisplay <font color=blue>As String</font color=blue>, strFileName <font color=blue>As String</font color=blue>
<font color=blue>Dim</font color=blue> lngBit <font color=blue>As Long</font color=blue>
<font color=blue>Dim</font color=blue> lngIndex <font color=blue>As Long</font color=blue>
<font color=blue>Dim</font color=blue> lngBitVal(0 <font color=blue>To</font color=blue> 7) <font color=blue>As Long</font color=blue>

<font color=green>' ** NOTE: ENTER YOUR FILE NAME HERE **</font color=green>
strFileName = "E:\Temp\error.log"


<font color=green>' Get a free handle to use to connect to a file</font color=green>
hFile = FreeFile

<font color=green>' Open the file in binary mode so we can read in the bytes</font color=green>
<font color=blue>Open</font color=blue> strFileName <font color=blue>For Binary</font color=blue> <font color=blue>As</font color=blue> #hFile

<font color=green>' Make the buffer big enough to read all the file and read it</font color=green>
<font color=blue>ReDim</font color=blue> bytData(1 <font color=blue>To</font color=blue> LOF(hFile) )
<font color=blue>Get</font color=blue> hFile, , bytData
<font color=blue>Close</font color=blue> hFile

<font color=green>' Build a string from the byte array so we can display it</font color=green>
strDisplay = StrConv(bytData, vbUnicode)
MsgBox strDisplay, vbInformation



<font color=green>'---------------------------------------------------------</font color=green>
<font color=green>' Now convert the first three chars to bit representations</font color=green>
<font color=green>' (This is to demonstrate how to get the bits out) </font color=green>
<font color=green>'---------------------------------------------------------</font color=green>

<font color=green>' First set up the bit vals array</font color=green>
lngBitVal(0) = 1
lngBitVal(1) = 2
lngBitVal(2) = 4
lngBitVal(3) = 8
lngBitVal(4) = 16
lngBitVal(5) = 32
lngBitVal(6) = 64
lngBitVal(7) = 128

<font color=green>' Now build a display of the first three chars from the file</font color=green>
strDisplay = ""
<font color=blue>For</font color=blue> lngIndex = 1 <font color=blue>To</font color=blue> 3

<font color=green>' Show the actual character in quotes</font color=green>
strDisplay = strDisplay &amp; _
Chr$(34) &amp; Chr$(bytData(lngIndex) ) &amp; Chr$(34) &amp; _
vbTab &amp; " "

<font color=green>' Perform a bitwise calculation on the current byte</font color=green>
<font color=green>' and build a binary string representation</font color=green>
<font color=blue>For</font color=blue> lngBit = 7 <font color=blue>To</font color=blue> 0 Step -1
strDisplay = strDisplay &amp; Abs(<font color=blue>CBool</font color=blue>(bytData(lngIndex) <font color=blue>And</font color=blue> lngBitVal(lngBit) ) )
<font color=blue>Next</font color=blue> lngBit

strDisplay = strDisplay &amp; vbNewLine
<font color=blue>Next</font color=blue> lngIndex


<font color=green>' Display the results</font color=green>
strDisplay = "Binary representation of first 3 chars" &amp; _
vbNewLine &amp; _
strDisplay
MsgBox strDisplay, vbInformation

<font color=blue>End Sub</font color=blue>
</pre>
Reply With Quote
  #3  
Old 12-18-2001, 04:07 AM
divil's Avatar
divil divil is offline
Funky Monkey

* Expert *
 
Join Date: Nov 2001
Location: England
Posts: 1,289
Default Re: comprestion or Bit information please

How do you post code with colouring like that?
__________________
MVP, C#
Now you see why evil will always triumph - because good is dumb.
Windows Forms and WPF user interface controls
Reply With Quote
  #4  
Old 12-18-2001, 07:49 AM
Thinker Thinker is offline
Iron-Fisted Programmer

Retired Moderator
* Guru *
 
Join Date: Jul 2001
Location: Fayetteville Arkansas USA
Posts: 18,127
Default Re: comprestion or Bit information please

You use markup tags. Read the forum FAQ, or download VolteFace's Post
Workshop from the CodeLibrary and see how he does it.
__________________
Posting Guidelines
Reply With Quote
  #5  
Old 12-18-2001, 08:19 AM
Banjo's Avatar
Banjo Banjo is offline
Hell's Angel

Retired Moderator
* Guru *
 
Join Date: Jul 2001
Location: Yorkshire, UK
Posts: 10,394
Default Re: comprestion or Bit information please

You will also want to get PostWriter's companion, codeTag. Scroll right to the bottom to get the latest version.
__________________
A wise one man once said "what you talking about dog breath"
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->