|
GetDirectories - Returns all the subdirectories of a directory
|
Total Hit (3212) |
«Code LangId=1»' Returns a collection holding all the subdirectories in a path
' that match search attributes (optionally it returns the entire path).
Function GetDirectories(path As String, Optional Attributes As VbFileAttribute, _
Optional IncludePath As Boolean) As Collection
Dim d
....Read More |
Rating
|
|
|
|
CBitArray - a class for dealing with large arrays of Boolean
|
Total Hit (2302) |
«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 (2229) |
«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 (2113) |
«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 (2150) |
«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 (2249) |
«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 (2501) |
«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 (2188) |
«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 (2758) |
«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 (1746) |
«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 (3568) |
«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 (1543) |
«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 (1591) |
«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
|
|
|
AddBackslash - Append a backslash to a path if needed
|
Total Hit (3087) |
«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 (2702) |
«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 (3063) |
«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 (3024) |
«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 (3201) |
«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 (3731) |
«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
|
|
|
|
|
|
GetAllFiles - Search files in a directory or directory tree
|
Total Hit (4646) |
«code LangId=1»Private Sub Command1_Click()
Dim col As Collection
'//Get all files from C:\ (No sub folder) which are older than 5 days and newer than 30 days
Set col = GetAllFiles("c:\", "*.*", False, 30, 5)
For Each f In col
Debug.Print FileDateTime(f) & "=>" & f
....Read More |
Rating
|
|
|
|
GetAttrDescr - The attributes of a file in a readable format
|
Total Hit (2611) |
«Code LangId=1»
' The attributes of a file in a readable format.
' It works also with open files, raises an error if the file doesn't exist.
Function GetAttrDescr(filename As String) As String
Dim result As String, attr As Long
' get file attributes as a bit-coded field
attr =
....Read More |
Rating
|
|