Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Setting a property in a class at runtime

Status
Not open for further replies.

sfunk

Technical User
Jan 22, 2002
107
US
Hello,

I have written a dll it has a Property called Status. I used the Class Builder addin. When I Let the Property from a form in my application it works fine - I can Get it from my Form just fine. When I try to Let the Property from within a Public Function in the dll I cannot Get it from my Form. Here is the snip of code from the dll. Could someone help out please.

Code:
Option Explicit
Dim strPath As String
-------------------
'local variable(s) to hold property value(s)
Private mvarStatus As String 'local copy
Public Property Let Status(ByVal vData As String)
'used when assigning a value to the property, on the left side of an assignment.
'Syntax: X.Status = 5
    mvarStatus = vData
End Property
-------------------------
Public Property Get Status() As String
'used when retrieving value of a property, on the right side of an assignment.
'Syntax: Debug.Print X.Status
    Status = mvarStatus
End Property
------------------
Public Function CRGo(ByVal strPath As String)
   
   Dim Status As String   
   On Error Resume Next

   If strPath = "" Then
      vData = "Path not provided"
      Exit Function
   Else
      vData = "Path provided"
   End If
   ....

Thank you for any suggestions.
Steve
 
Where is the instantiation of the object with the property.

e.g.
Dim objClass as new myclass
If strPath = "" Then
objClass.Status = "Path not provided"
Exit Function
Else
objClass.Status = "Path provided"
End If

vData is not defined anywhere. It may be in the class properties as a parameter name but that is not the name of the property. Forms/Controls Resizing/Tabbing Control
Compare Code (Text)
Generate Sort Class in VB or VBScript
 
Hi John,

Thank you for responding.

I have two items. I built a ActiveX dll. And I have my application that is using the dll. When I instantiate the object in the application and Use the Control statement below in the application, it works great.

Code:
   If strPath = "" Then
      objCRJet.Status = "Empty"
   Else
      objCRJet.Status = "Full"
   End If

I want to put this control statement in the dll. strPath is passed to the Public Function in the dll that I posted. I would like this check to happen in the dll.

I hope this is enough info for you. The snip that I have in my first message of this thread is the top part of the dll.

Sincerely,
Steve
 
Do you need to specify the return value from the function

Public Function CRGo(ByVal strPath As String) As String

Dim Status As String
On Error Resume Next

If strPath = "" Then
vData = "Path not provided"
CRGo = vData
Exit Function
Else
vData = "Path provided"
End If
....

CRGp = vData

End Function
Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top