Total Visual SourceBook

Total Visual SourceBook CD and Printed Manual

Microsoft Access/ Office 2016, 2013, 2010, and 2007 Version
is Shipping!

New features in Total Visual SourceBook for Access, Office 2007 and VB6

Supports Access/Office 2016, 2013, 2010 and 2007, and Visual Basic 6.0!

Separate version for Access/Office 2003, 2002, and 2000.

Separate version for:
Access 97/95


View all FMS products for Microsoft AccessAll Our Microsoft Access Products

SourceBook Info:

Why SourceBook?

 

"The code is exactly how I would like to write code and the algorithms used are very efficient and well-documented."

Van T. Dinh, Microsoft MVP

 

 

 

Microsoft Access, Office/VBA, VB6 Modules royalty-free source code libraryMicrosoft Access Modules royalty-free source code libraryMicrosoft Access VBA and VB6 Module Library Free trial of Total Visual SourceBook for Microsoft Access, Office, VB6 and VBA

Class: UUEncode in Category General VBA/VB6 : Encryption and Compression from Total Visual SourceBook

Class that encodes and decodes files using UU Encoding with VB6 and VBA.

UU Encoding is an algorithm for converting binary data to 6-bit ASCII. This is often needed to send binary files through internet mail gateways. UU Encoding is also commonly used in internet newsgroups for posting binary data. UU Encoding breaks a group of 3 eight bit characters (24 bits) into 4 six bit characters (also 24 bits) and then adds 32 (a space) to each six bit character. This maps it into a transmittable character set. These characters are: !"#$%&'()*+,-./ 0123456789:;=? @ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_

Procedure List

Procedure Name

Type

Description

(Declarations) Declarations Declarations and private variables for the CUUEncode class
InputFileName Property Get the name of the input file.
OutputFileName Property Get the name of the output file.
Decode Method Decode a file encoded with UUEncoding.
Encode Method Encode a file using UU Encoding.
dblToLong Private Perform an unsigned conversion from a Double value to a Long value. This function correctly handles doubles greater than 2,147,483,647 and less than or equal to 4,294,967,295.
DecodeByte Private Decode a single byte.
EncodeByte Private Encode a byte by manipulating the byte to ensure that it is a printable character code.
GetFileName Private Get the name and extension of a fully qualified file name.
GetFilePath Private Get the path part of a string.
IntToByte Private Perform an unsigned conversion from an integer value to a byte value. This procedure correctly handles any integer value. For example, lngNumber = -1 assigns -1 to the variable lngNumber. However, lngNumber = IntToLong(-1) assigns 65,535 to lngNumber.
IntToLong Private Convert an integer value to a long value, treating the integer as unsigned.
LongToInt Private Perform an unsigned conversion from a long integer value to an integer value.
MakeInt Private Combine two bytes into an integer.
MakeLong Private Combine two words (integers) into a long integer. This routine correctly handles negative input values.
MakePrintable Private Take three bytes and convert them into 4 printable characters.
ReadFile Private Read the specified number of bytes from the file. Using this function significantly increases the speed of processing files. The alternative to using a file buffer is reading a byte at a time from the file
Shlb Private Shift a byte value left by the specified number of bits. Left shifting is a multiplication operation. For the number of bits to shift to the left, raise two to that power, then multiply the result by the original value.
Shrb Private Shift a byte value right the selected number of places. Right shifting is a division operation. For the number of bits to shift to the right, raise two to that power, then divide the original value by the result.
UnMakePrintable Private Take 4 printable characters and convert them into 3 bytes.

Example Code for Using Class: UUEncode

' Example of CUUEncode to encode and decode files using UU Encoding.
'
' To try this example, do the following:
' 1. Create a new form
' 2. Create a command button named 'cmdTest'
' 3. Create a text box named txtProgress
' 4. Paste all the code from this example to the new form's module.
' 5. Run the form

' This example assumes that the sample files are located in the folder named by the following constant.
Private Const mcstrSamplePath As String = "C:\TVSBSamp"

' By defining the class WithEvents, you can capture the Progress event to display information to your user.
' To use events, this module must be a class or form/report. If you don't want to capture the Progress event, you can use a regular module.
Private WithEvents mclsUUEncode As CUUEncode

Private Sub cmdTest_Click()
  ' Comments: Examples of encoding and decoding files using UU Encoding.
  '           UU Encoding is an algorithm for converting binary data to 6-bit ASCII.
  '           This is often needed to send binary files through internet mail gateways.
  '           UU Encoding is also commonly used in internet newsgroups for posting binary data.
  '           UU Encoding breaks a group of 3 eight bit characters (24 bits) into 4 six bit characters (also 24 bits) and
  '           then adds 32 (a space) to each six bit character. This maps it into a transmittable character set.

  Const cstrOriginal As String = mcstrSamplePath & "\original.bmp"
  Const cstrEncode As String = mcstrSamplePath & "\encode.UUE"
  Const cstrDecode As String = mcstrSamplePath & "\decode.bmp"

  ' Initialize class
  Set mclsUUEncode = New CUUEncode

  With mclsUUEncode
    ' Example of creating a UUEncode file from a file
    .InputFileName = cstrOriginal
    .OutputFileName = cstrEncode
    .Encode
    MsgBox "Compressed file created: " & cstrEncode

    ' Decoding a UU encoded file
    .InputFileName = cstrEncode
    .OutputFileName = cstrDecode
    .Decode
    MsgBox "New file created: " & cstrDecode
  End With

  ' Close class
  Set mclsUUEncode = Nothing

End Sub

Private Sub mclsUUEncode_FileProgress(dblPercentage As Double)
  ' Comments: This procedure captures the Progress Event and reveals the percentage completion for the file that's being compressed or decoded.
  '           This example puts the percentage in a text box on the form so you can see the progress
  ' Params  : dblPercentage       Percent of completion between 0 and 1

  Me.txtProgress = Format$(dblPercentage, "Percent")

  ' Give time so Access can refresh the screen
  DoEvents
End Sub

Microsoft Access Module LibraryOverview of Total Visual SourceBook

The source code in Total Visual SourceBook includes modules and classes for Microsoft Access, Visual Basic 6 (VB6), and Visual Basic for Applications (VBA) developers. Easily add this professionally written, tested, and documented royalty-free code into your applications to simplify your application development efforts.

Additional Resources