When you create methods in a class, you can call them in the rest of your code just
as you would call methods for any standard VB class.
To provide methods for your class, just create Public procedures in the class module
(both Sub and Function procedures will work). Code from other parts of the application or
in ActiveX controllers can then call these procedures directly as methods of the object Class.
The example in Listing 12.1 defines a Public Sub procedure SearchPath in the class
module FileFind. Code residing elsewhere in the application can call the SearchPath method
of the object Class. The calling code passes to the method the name of the directory to search
and a file specification to search for.
IMPLEMENTING A METHOD WITH A Public PROCEDURE
[In the Class module]
Public Sub SearchPath(strDirToSearch As String, _
'Add a backslash to the directory
'name if one's not there already
If Right(strDirToSearch, 1) <> "\" Then
= strDirToSearch & "\"
'Get the name of the first file in the
'directory fitting the specified pattern
Dim strName As String
strName = Dir$(strDirToSearch & strFileSpec)
'Loop through all file names in the directory
'fitting the specified pattern
Do Until strName = ""
'Add this file to
'get the next file
name in the list
strName = Dir$
[In the General Declarations of a Form]
Private FF As FileFind
[In the calling routine]
Private Sub cmdFindFiles_Click()
Set FF = New FileFind