|(Declarations)||Declarations||Declarations and private variables for the CCRC32 class.|
|InputFileName||Property||Get the name of the input file.|
|GetCRCFromFile||Method||Generate a CRC for the file specified in the InputFile property.|
|GetCRCFromString||Method||Generate a CRC for a string using the Unicode version of this method. For an ASCII version, see GetCRCFromStringAscii.|
|GetCRCFromStringAscii||Method||Generate a CRC for a string using the ASCII version of this method. For the Unicode version, use GetCRCFromString.|
|ConstructCRCTable||Private||Fill the CRC table with precalculated values. This is more efficient than calculating CRC's each time they are needed.|
|ReadFile||Private||Read the specified number of bytes from the file which significantly increases the speed of processing files. The alternative to using a file buffer is reading a byte at a time from the file.|
|UpdateCRC32||Private||Calculate the new CRC based on the current CRC and the byte value.|
' Example of CCRC32 to calculate the 32-bit CRC of a file or string ' ' To try this example, do the following: ' 1. Create a new user form ' 2. Create a command button named 'cmdTest' ' 3. Paste all the code from this example to the new form's module. ' 4. 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 mclsCRC32 As CCRC32 Private Sub cmdTest_Click() ' Comments: Examples of converting files and strings to a 32-bit Cyclic Redundancy Check (CRC) value; can also be used for Checksum Dim lngCRCValue As Long Dim strString As String ' Initialize class Set mclsCRC32 = New CCRC32 ' Example of creating a 32-bit CRC value for a file mclsCRC32.InputFileName = mcstrSamplePath & "\sample.mdb" lngCRCValue = mclsCRC32.GetCRCFromFile() MsgBox "CRC File Value:" & lngCRCValue ' Example of creating a 32-bit CRC value for a string strString = "One small step for [a] man; one giant leap for mankind" lngCRCValue = mclsCRC32.GetCRCFromString(strString) MsgBox "String CRC Value: " & lngCRCValue ' Close class Set mclsCRC32 = Nothing End Sub Private Sub mclsCRC32_Progress(dblPercentage As Double) ' Comments: This procedure captures the Progress Event and reveals the percentage completion for the file that's being compressed ' This example puts the information on the Immediate Window. You could show the information on a form as text or display a graphic. ' Params : dblPercentage Percent of completion between 0 and 1 Debug.Print "Percent done: " & Format$(dblPercentage, "Percent") End Sub
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.
Total Visual SourceBook is written for the needs of a developer using a source code library covering the many challenges you face. Countless developers over the years have told us they learned some or much of their development skills and tricks from our code. You can too!
Supports Access/Office 2016, 2013, 2010 and 2007, and Visual Basic 6.0!
"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