Results 1 to 9 of 9

Thread: Visual Basic (how original)

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 1999
    Location
    NY, USA
    Posts
    270

    Post

    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
    [email protected]
    ICQ: 15743470
    AIM: TomY10
    PERL, JavaScript and VB Programmer

  2. #2
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Post

    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

  3. #3
    Member
    Join Date
    Oct 1999
    Location
    Richmond, Virginia
    Posts
    41

    Post

    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

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 1999
    Location
    NY, USA
    Posts
    270

    Post

    Thanx for the info. Does anybody know where to start?

  5. #5
    Member
    Join Date
    Oct 1999
    Location
    Richmond, Virginia
    Posts
    41

    Post

    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



  6. #6
    New Member
    Join Date
    Oct 1999
    Posts
    1

    Post

    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!


  7. #7
    Junior Member
    Join Date
    Oct 1999
    Posts
    16

    Post

    You can get the XCeedZip.OCX, it works like pkzip.

  8. #8
    Lively Member Bios's Avatar
    Join Date
    Nov 1999
    Location
    Richton Park, IL, USA
    Posts
    71

    Post

    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

  9. #9

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 1999
    Location
    NY, USA
    Posts
    270

    Post

    Wow, complicated.

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