Click here to Skip to main content
15,922,650 members
Home / Discussions / Visual Basic
   

Visual Basic

 
AnswerRe: Multiple Header in DataGrid or ListView Pin
| Muhammad Waqas Butt |18-Dec-05 4:04
professional| Muhammad Waqas Butt |18-Dec-05 4:04 
Questionproblem working with dll on server Pin
uktrips00715-Dec-05 2:23
uktrips00715-Dec-05 2:23 
AnswerRe: problem working with dll on server Pin
Ray Cassick15-Dec-05 3:53
Ray Cassick15-Dec-05 3:53 
GeneralRe: problem working with dll on server Pin
uktrips00715-Dec-05 19:11
uktrips00715-Dec-05 19:11 
GeneralRe: problem working with dll on server Pin
Ray Cassick16-Dec-05 3:28
Ray Cassick16-Dec-05 3:28 
QuestionCombo Box with Tree Dropdown view Pin
JanakKoshia15-Dec-05 1:59
JanakKoshia15-Dec-05 1:59 
AnswerRe: Combo Box with Tree Dropdown view Pin
Ray Cassick15-Dec-05 3:57
Ray Cassick15-Dec-05 3:57 
QuestionVB6: compression problem Pin
-- NA --15-Dec-05 0:14
-- NA --15-Dec-05 0:14 
Hi all, don't know if anyone can help with this obscure question. I'm currently busy with a project (for school) involving data compression. We'll only work with plain text files which makes life simpler. The problem: a way to save space we came up with is to chop off one bit off each byte, because for character codes < 128 only 7 bits are needed. I've written code that does this, it converts an input file in chunks of 8 bytes, except it corrupts data (half). Here is the code I'm using:

Compression:

file_name = cdsave.FileName<br />
file_length = FileLen(file_name)<br />
fnum = FreeFile<br />
ReDim bytes(1 To file_length)<br />
Open file_name For Binary As #fnum<br />
    Get #fnum, 1, bytes<br />
Close #fnum<br />
Kill file_name<br />
For i = 1 To file_length Step 8<br />
    txt = vbNullString<br />
    txt2 = vbNullString<br />
        For isub = 0 To 7 'bytes to process each time.<br />
            If file_length < i + isub Then Exit For<br />
            txt = txt & Right$(Format$(Dec2Base(bytes(i + isub), 2), "00000000"), 7)<br />
        Next isub<br />
        For converttxt = 0 To 6<br />
            txt2 = txt2 & ChrW(Base2Dec(Mid$(txt, (converttxt * 8) + 1, 8), 2))<br />
        Next converttxt<br />
    fnum = FreeFile<br />
    Open file_name For Append As #fnum<br />
         Print #fnum, txt2;<br />
    Close #fnum<br />
Next i<br />


Decompression:

txt = vbNullString<br />
txtInPhase = vbNullString<br />
<br />
intEndFile = FreeFile<br />
<br />
file_name = txtFile.Text<br />
file_length = FileLen(file_name)<br />
fnum = FreeFile<br />
ReDim bytes(1 To file_length)<br />
Open file_name For Binary As #fnum<br />
    Get #fnum, 1, bytes<br />
Close #fnum<br />
If Dir(cdSave.FileName) = cdSave.FileName Then Kill cdSave.FileName<br />
For i = 1 To file_length Step 7<br />
txt = vbNullString<br />
txt2 = vbNullString<br />
    For isub = 0 To 6 'bytes to process each time.<br />
        If file_length < i + isub Then Exit For<br />
        txt = txt & Format$(Dec2Base(Format$(bytes(i + isub)), 2), "00000000")<br />
    Next isub<br />
    For converttxt = 0 To 7<br />
        txt2 = txt2 & ChrW(Base2Dec(Mid$(txt, (converttxt * 7) + 1, 7), 2))<br />
    Next converttxt<br />
fnum = FreeFile<br />
Open cdSave.FileName For Append As #fnum<br />
     Print #fnum, txt2;<br />
Close #fnum<br />
Next i


What happens to the data:

Input: Hello. This is a test string for demonstration purposes.
Output: Ollo. Thigpis a tesq|string for OemonstrOtion purgses.

If someone could take some time to look at this I'd be immensely appreciative. I don't expect anyone to do my work for me, and don't worry, the deadline is still far away. Smile | :)

Paul



-- modified at 6:41 Thursday 15th December, 2005

modified 18-Jul-18 11:59am.

AnswerRe: VB6: compression problem Pin
Steve Pullan15-Dec-05 13:21
Steve Pullan15-Dec-05 13:21 
GeneralRe: VB6: compression problem Pin
-- NA --18-Dec-05 21:47
-- NA --18-Dec-05 21:47 
QuestionTask Scheduling in vb.net Pin
Malayil alex14-Dec-05 23:18
Malayil alex14-Dec-05 23:18 
QuestionRetreiving Data As XML from SQL Server 2000 in VB.net Pin
peramkirankumar14-Dec-05 20:49
peramkirankumar14-Dec-05 20:49 
Questionapplication to store ms-word document into a table Pin
agauga14-Dec-05 20:19
agauga14-Dec-05 20:19 
AnswerRe: application to store ms-word document into a table Pin
Ray Cassick15-Dec-05 4:57
Ray Cassick15-Dec-05 4:57 
QuestionRetrieving colours from form Pin
Deemo14-Dec-05 20:00
Deemo14-Dec-05 20:00 
AnswerRe: Retrieving colours from form Pin
Roy Heil15-Dec-05 4:50
professionalRoy Heil15-Dec-05 4:50 
GeneralRe: Retrieving colours from form Pin
Deemo15-Dec-05 9:11
Deemo15-Dec-05 9:11 
Questiongetting data with winsock Pin
Rohithie14-Dec-05 19:07
Rohithie14-Dec-05 19:07 
AnswerRe: getting data with winsock Pin
Dave Kreskowiak15-Dec-05 5:27
mveDave Kreskowiak15-Dec-05 5:27 
QuestionHi...need help for windows process name Pin
BK Heng14-Dec-05 15:40
BK Heng14-Dec-05 15:40 
AnswerRe: Hi...need help for windows process name Pin
Dave Kreskowiak15-Dec-05 5:22
mveDave Kreskowiak15-Dec-05 5:22 
GeneralRe: Hi...need help for windows process name Pin
BK Heng15-Dec-05 13:19
BK Heng15-Dec-05 13:19 
QuestionWndDebugger and ProcessExplorer Pin
devvvy14-Dec-05 15:08
devvvy14-Dec-05 15:08 
QuestionReminder for client Pin
linardi14-Dec-05 15:02
linardi14-Dec-05 15:02 
QuestionAdd Serial Number while making Installer in VB.net Pin
Rachel Lam14-Dec-05 14:53
Rachel Lam14-Dec-05 14:53 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.