|
CBitArray - a class for dealing with large arrays of Boolean
|
Total Hit (2390) |
«Code LangId=1»
' ------------------------------------------------------------------------
' The CBITARRAY class
'
' simiulates an array of Boolean values
' saves memory by packing one element in one bit
'
' IMPORTANT: you make make ITEM the default member for this class
' do
....Read More |
Rating
|
|
|
CombSort - A very efficient algorithm
|
Total Hit (2298) |
«Code LangId=1»' Comb Sort an array of any type
'
' CombSort is faster than all but QuickSort and close to it.
' On the other hand, the code is much simpler than QuickSort
' and can be easily customized for any array type
' This routine is based on an article appeared on the Byte
' magazine i
....Read More |
Rating
|
|
|
Filter - A replacement for VB6's Filter function under VB5
|
Total Hit (2187) |
«Code LangId=1»' A replace for the Filter function under VB4 and VB5
'
' Note that the source array is modified. For this reason
' this is declared as a Sub rather than a Function
Sub Filter(arr() As String, ByVal Search As String, Optional ByVal Include As _
Boolean, Optional ByVal Comp
....Read More |
Rating
|
|
|
FilterDuplicates - Delete duplicate items in an array
|
Total Hit (2226) |
«Code LangId=1»
' Filter out duplicate values in an array and compact
' the array by moving items to "fill the gaps".
' Returns the number of duplicate values
'
' it works with arrays of any type, except objects
'
' The array is not REDIMed, but you can do it easily using
' the following co
....Read More |
Rating
|
|
|
|
TransposeMatrix - Rotate a bi-dimensional array
|
Total Hit (2331) |
«Code LangId=1»
' evaluate the transposed matrix
'
' a transposed matrix is the array you get when
' you "rotate" a bi-dimensional array
Function TransposeMatrix(arr() As Double) As Double()
Dim startRow As Long, startCol As Long
Dim endRow As Long, endCol As Long
Dim r As Lon
....Read More |
Rating
|
|
|
HasDuplicateValues - Check if an array has duplicate values
|
Total Hit (2612) |
«Code LangId=1»' Returns True if an array contains duplicate values
' it works with arrays of any type
Function HasDuplicateValues(arr As Variant) As Boolean
Dim col As Collection, index As Long
Set col = New Collection
' assume that the array contains duplicates
HasDu
....Read More |
Rating
|
|
|
ListBoxEnsureVisible - Ensure that a ListBox element is visible
|
Total Hit (2264) |
«Code LangId=1»' ensure that a listbox item is visible
' if the second argument is omitted, the index of current item is used
'
' NOTE: uses the ListBoxVisibleItems function
Sub ListBoxEnsureVisible(lst As ListBox, Optional ByVal itemIndex As Long = -1)
Dim visibleCount As Long
....Read More |
Rating
|
|
|
NdxShellSort -Sort Indexed Arrays using ShellSort
|
Total Hit (2821) |
«Code LangId=1»' Indexed ShellSort of an array of any type
'
' Indexed Sorts are sort procedures that sort an index array
' instead of the main array. You can then list the items in
' sorted member by simply scanning the index, as in
' For i = 1 To numEls: Print arr(ndx(i)): Next
'
' NUMEL
....Read More |
Rating
|
|
|
QuickSort - Sort Arrays using the QuickSort Algorithm
|
Total Hit (1796) |
«Code LangId=1»' QuickSort an array of any type
' QuickSort is especially convenient with large arrays (>1,000
' items) that contains items in random order. Its performance
' quickly degrades if the array is already almost sorted. (There are
' variations of the QuickSort algorithm that work goo
....Read More |
Rating
|
|
|
RLECompress - Compress a block of memory using RLE algorithm
|
Total Hit (3621) |
«Code LangId=1»Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (dest As _
Any, source As Any, ByVal Bytes As Long)
' compress a block of memory (a string, an array, a bitmap)
' using the RLE compression algorithm
'
' Returns True if the block has been compressed,
'
....Read More |
Rating
|
|
|
SemiCRC - A fast CRC-like algorithm
|
Total Hit (1592) |
«Code LangId=1»
' Evaluate the 16-bit Checksum of an array of bytes
Function SemiCRC(bSource() As Byte) As Long
Dim lngCRC As Long
Dim lngTemp As Long
Dim lngSize As Long
Dim I As Long
Const divisor As Long = 32768
lngSize = UBound(bSource())
For I = 0 T
....Read More |
Rating
|
|
|
ShellSort - Sort Arrays using the ShellSort Algorithm
|
Total Hit (1657) |
«Code LangId=1»
' ShellSort an array of any type
'
' ShellSort behaves pretty well with arrays of any size, even
' if the array is already "nearly-sorted", even though in
' particular cases BubbleSort or QuickSort can be more efficient.
'
' LASTEL is the index of the last item to be sorted,
....Read More |
Rating
|
|
|
ArrayDeleteElement - Deleting an element in any type of array
|
Total Hit (2642) |
«Code LangId=2»' A generic routine that deletes an element in any type of array.
' Example: deleting the 2nd element of the array arr
' ArrayDeleteElement(arr, 1)
Sub ArrayDeleteElement(ByVal arr As Array, ByVal index As Integer)
' Shift elements from arr(index+1) to arr(index).
....Read More |
Rating
|
|
|
ArrayInsertElement - Inserting an element in any type of array
|
Total Hit (2695) |
«Code LangId=2»' A generic routine that inserts an element in any type of array.
' Example: inserting an entry of value 5 between the 1st and 2nd entry of the
' array arr
' ArrayInsertElement(arr, 1, 5)
Sub ArrayInsertElement(ByVal arr As Array, ByVal index As Integer, _
Optional By
....Read More |
Rating
|
|
|
ArrayListJoin - Merging two ArrayList objects
|
Total Hit (2947) |
«Code LangId=2»' A reusable function that merges two ArrayList objects
' Example:
' Dim al As New ArrayList()
' al.Add("Jack")
' al.Add("Mary")
' val.Add("Bob")
' al.Add("Tom")
'
' Dim al2 As New ArrayList()
' al2.Add("Frank")
' al2.Add("Lee")
' a
....Read More |
Rating
|
|
|
FilterDuplicates - Delete duplicate items in an array
|
Total Hit (3273) |
«Code LangId=2»
' Filter out duplicate values in an array and compact
' the array by moving items to "fill the gaps".
' Returns the number of duplicate values
'
' The array is not REDIMed, but you can do it easily using
' the following code:
' a() is a string array
' dups = FilterDu
....Read More |
Rating
|
|
|
|
AddBackslash - Append a backslash to a path if needed
|
Total Hit (3156) |
«Code LangId=1»' Append a backslash (or any character) at the end of a path
' if it isn't there already
Function AddBackslash(Path As String, Optional Char As String = "\") As String
If Right$(Path, 1) <> Char Then
AddBackslash = Path & Char
Else
AddBackslash = Path
....Read More |
Rating
|
|
|
ChangeFileExtension - Modify the extension in a file name
|
Total Hit (2780) |
«Code LangId=1»
' Change the extension of a file name
' if the last argument is True, it adds the extension even if the file doesn't
' have one
Function ChangeFileExtension(FileName As String, Extension As String, _
Optional AddIfMissing As Boolean) As String
Dim i As Long
For
....Read More |
Rating
|
|
|
|
|
CompareFiles - Check whether two files contain the same data
|
Total Hit (3149) |
«Code LangId=1»' compare two files
' return True if they're equal
Function CompareFiles(ByVal file1 As String, ByVal file2 As String) As Boolean
Dim fnum1 As Integer, isOpen1 As Boolean
Dim fnum2 As Integer, isopen2 As Boolean
Dim buffer1 As String, buffer2 As String
Dim byt
....Read More |
Rating
|
|
|
ConcatenateFiles - Merge multiple text files in one
|
Total Hit (3093) |
«Code LangId=1»
' Concatenate a variable number of text files into a single result file
'
' Params:
' - ResultFile: the complete path of the result file you want to create
' - Separator: a string that is written when a file is added to the result
' file.
' Note: this string can conta
....Read More |
Rating
|
|
|
DirExists - Check that a directory exists
|
Total Hit (3275) |
«Code LangId=1»
' Return True if a directory exists
' (the directory name can also include a trailing backslash)
Function DirExists(DirName As String) As Boolean
On Error GoTo ErrorHandler
' test the directory attribute
DirExists = GetAttr(DirName) And vbDirectory
ErrorHandler:
....Read More |
Rating
|
|
|
|
FileExists - Check that a file exists
|
Total Hit (3803) |
«Code LangId=1»' Return True if a file exists
Function FileExists(FileName As String) As Boolean
On Error GoTo ErrorHandler
' get the attributes and ensure that it isn't a directory
FileExists = (GetAttr(FileName) And vbDirectory) = 0
ErrorHandler:
' if an error occurs, this
....Read More |
Rating
|
|
|
|
|
BubbleSort - Sort Arrays using the BubbleSort Algorithm
|
Total Hit (3097) |
«Code LangId=1»
' Bubble Sort an array of any type
' BubbleSort is especially convenient with small arrays (1,000
' items or fewer) or with arrays that are already almost sorted
'
' NUMELS is the index of the last item to be sorted, and is
' useful if the array is only partially filled.
'
'
....Read More |
Rating
|
|