|
-
Sep 14th, 2001, 07:34 AM
#1
Thread Starter
Fanatic Member
Cannot run a function in a class project
Hi Again All,
I am trying to use one function in a class module in another function of another class module. Both class modules are in the same class project. I keep getting an error that the Sub or Function was not defined. If I move the function into the class module I am calling it from everything works fine.
Could some one please tell me what I am doing wrong.
Thanks
-
Sep 14th, 2001, 07:38 AM
#2
Frenzied Member
The error may be because of the way you are declaring the sub or function. From the MSDN help;
[Private | Public | Friend] [Static] Sub name [(arglist)]
[statements]
[Exit Sub]
[statements]
End Sub
The Sub statement syntax has these parts:
Public - Optional. Indicates that the Sub procedure is accessible to all other procedures in all modules. If used in a module that contains an Option Private statement, the procedure is not available outside the project.
Private - Optional. Indicates that the Sub procedure is accessible only to other procedures in the module where it is declared.
Friend - Optional. Used only in a class module. Indicates that the Sub procedure is visible throughout the project, but not visible to a controller of an instance of an object.
Static - Optional. Indicates that the Sub procedure's local variables are preserved between calls. The Static attribute doesn't affect variables that are declared outside the Sub, even if they are used in the procedure.
Perhaps you should be using
Friend Sub xxxxxx
etc
'Buzby'
Visual Basic Developer
"I'm moving to Theory. Everything works there."
-
Sep 14th, 2001, 07:49 AM
#3
Thread Starter
Fanatic Member
I have added my code below. I have the function that I am calling defined as a public function so I don't know what gives.
Both file.cls and string.cls are in the same project.
In File.cls
Code:
Public Function CreateFolder(ByVal _
CompleteDirectory As String) As Integer
drivePart = GetPart(CompleteDirectory, "\")
End Function
In String.cls
Code:
Public Function GetPart(InputString As String, Delimiter As String) As String
' Takes a string separated by "delimiter", splits off 1 item, and shortens the string so that the
' next item is ready for removal.
Dim c As Integer
Dim Item As String
c = 1
Do
If Mid$(InputString, c, 1) = Delimiter Then
Item = Mid$(InputString, 1, c)
InputString = Mid$(InputString, c + 1, Len(InputString))
GetPart = Item
Exit Function
End If
c = c + 1
Loop
End Function
-
Sep 14th, 2001, 07:53 AM
#4
-= B u g S l a y e r =-
you might wanna trie this:
VB Code:
Public Function CreateFolder(ByVal _
CompleteDirectory As String) As Integer
Dim s as new String '(object of type string.cls ... bad naming though :) )
drivePart = s.GetPart(CompleteDirectory, "\")
End Function
-
Sep 14th, 2001, 08:18 AM
#5
Thread Starter
Fanatic Member
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|