Click to See Complete Forum and Search --> : Visual Basic (how original)
Compwiz
Oct 8th, 1999, 05:58 AM
Is it possible to compress files with VB? I mean actually coding w/ VB and not some dll or ocx. Thanx!
------------------
Tom Young, 14 Year Old
tom@e-bizinternet.com
ICQ: 15743470
AIM: TomY10
PERL, JavaScript and VB Programmer
MartinLiss
Oct 9th, 1999, 11:52 AM
I suppose you could, but you would have to come up with your own scheme, and it probably would not be very efficient or quick when you were done. I don't know a lot about how compacting routines are coded, but one thing I believe they do is to look for things like multiple spaces in a row, which they change to a simple marker that records how many spaces there where, so that the number of spaces can be restored when the file is uncompacted.
------------------
Marty
TheLeeMan
Oct 15th, 1999, 02:17 AM
In compressions the computer scans through the file (or text) searching for strings of information that occure frequently (such as "09CD21B8"). Once it finds a common string it replaces this string throughout the file with a short string that it adds to it's "dictionary". Once the file is decompressed the computer reads the dictionary and replaces the shorter "code works" with the actual information. This way when transmitted the file size is decreased while the information in the file is constant.
This is possible do accomplish in VB, though because of VB's speed completing these routines on a large file (or any file >5k) would take to long to make it practicle. Better just to stick to an ocx or dll created using C. VB just cann't cut it when high speed data manipulation is concerned.
Feel free to comment. Tell me if you get some compression created. I would be interested in seeing it.
TheLeeMan
Compwiz
Oct 16th, 1999, 07:25 AM
Thanx for the info. Does anybody know where to start?
TheLeeMan
Oct 19th, 1999, 03:11 AM
Start simple. Put a textbox and two lists on a form, fill list one with the short text strings to replace and list2 with the shorted string to replace it with. This should (untested) run through the list boxes and text searching for the items in list1 and substituting list2.
Extremly unefficient i know. I should use the InStr command but then I would be doing everything for you. Don't actually use this code, just think of it as a guide.
(untested)
txt = text1
for x = 0 to list1.listcount - 1
z = ""
t = len(list1.text)
for y = t to dim(txt)-t,t
r = right(left(txt,y),t)
if r = list1.text then
z = z & list2.list(x)
else
z = z & r
end if
next
txt = z
next
text1 = txt
------------------
TheLeeMan
Slysi15
Oct 28th, 1999, 08:55 PM
You can use encryption to compress a document. When make a zip file with PKZIP that is protected with a password. The file is encrypted and compressed using the same scheme.
As with all file manipulation if VB, Compression and Encryption are Slow! And i do
suggest you get an OCX.
But you can write dodgy Compression schemein VB.
It could work something like this.
1. Find the most common groups of letters in the file.
2. Use the multiplication of all ASCII characters in those groups to seed a random number generator.
3. Create a substition libaray.
4. Substitute the random groups in place of the original groups.
N.B (for compression these randomized groups must be shorter than the groups you are replacing.)
This is not tested! And probably won't work!
csantos
Oct 28th, 1999, 09:02 PM
You can get the XCeedZip.OCX, it works like pkzip.
Bios
Nov 3rd, 1999, 06:54 AM
ok...I've made this sort of thing before...all you have to do is use the following code structure...
1.) Collect User inputs
2.) input the file to a variable or listbox
using the OPEN command
3.) Parse through the coding, and look for
any char. that is not used at all in the
file.
4.) now the hard part...Parse through the
file this time looking for common text
and find the one with the largest
overall string value .
(occurances * String Length)
5.) replace all of the occurances of the
string you found with one of the strings
found in step 3.
6.) Now, add text to the top of the file,
something like 'd=EE322DE'
(unused Char=common String)
7.) the just repeat step 3 until you run
out of common charecters, or run out
of unused charecters.
8.) Write the file using the OPEN command
to decompress the file all you have to do is parse the top of the file and take all of your stuff like 'd=EE322DE' and remove it, and search through the file for all 'd' and replace it with a 'EE322DE'
...And that...is that.
------------------
Bios
Age: 16
VB, C, Perl, Java (Script), HTML, ASP Programer
Compwiz
Nov 13th, 1999, 05:19 AM
Wow, complicated.
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.