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

Module: Search in Category General VBA/VB6 : Searching and Sorting from Total Visual SourceBook

Binary and Linear Search routines and Soundex function in VBA and VB6.

Procedure List

Procedure Name

Type

Description

(Declarations) Declarations Declarations and private variables for the modSearch module
BinarySearchVariant Procedure Use a binary search to find a value in an array. The array must be zero based and sorted for this procedure to function correctly. Please note that this function works on arrays of variants, but not a variant array.
LinearSearchVariant Procedure Use a linear search to find a value in an array. The array must be zero based and sorted for this procedure to function correctly. Please note that this function works on arrays of variants, but not a variant array.
LinearSearchVariantUnsorted Procedure Use a linear search to find a value in an array. This function is not optimized for sorted data. See LinearSearchVariant for a function that is optimized for Sorted Data. The array must be zero based and sorted for this procedure to function correctly. Please note that this function works on arrays of variants, but not a variant array.
Soundex Procedure Create a Soundex key for a string which is helpful for finding close but not exact data, such as de-duping addresses and spelling differences/typos between names. Soundex is based on the principle that English words can be distinguished by their consonants. The Soundex algorithm generates a string based on the first character of the string, followed by the consonants contained in the string.

Example Code for Using Module: Search

' Example of modSearch
'
' To try this example, do the following:
' 1. Create a new 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

Private Sub cmdTest_Click()
  Dim avarIn() As Variant
  Dim lngIndex As Long
  Dim i As Integer
  Dim dblFindItem As Double

  Randomize Timer

  ' Create array
  ReDim avarIn(1000)
  For i = 0 To 1000
    avarIn(i) = i
  Next i

  ' Example of LinearSearchVariantUnsorted
  dblFindItem = Int((1000 - 1 + 1) * Rnd + 1)
  lngIndex = LinearSearchVariantUnsorted(avarIn, dblFindItem)
  Debug.Print " LinearSearchVariantUnsorted Item " & dblFindItem & " is at " & lngIndex

  ' Example of LinearSearchVariant
  dblFindItem = Int((1000 - 1 + 1) * Rnd + 1)
  lngIndex = LinearSearchVariant(avarIn, dblFindItem)
  Debug.Print "LinearSearchVariant Item " & dblFindItem & " is at " & lngIndex

  ' Example of BinarySearchVariant
  dblFindItem = Int((1000 - 1 + 1) * Rnd + 1)
  lngIndex = BinarySearchVariant(avarIn, dblFindItem)
  Debug.Print "BinarySearchVariant Item " & dblFindItem & " is at " & lngIndex

  ' Example of Soundex (defaults to 4 characters)
  Debug.Print Soundex("Microsoft Corporation")
  ' Generate a 7 character soundex
  Debug.Print Soundex("Microsoft Corporation", 7)

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