-
hi,
i've just started fooling around with classes in vb.
could someone tell me why this is returning with an error saying 'method or data member not found'?
thanks
//class module
Option Explicit
Private c_name
Public Property Get labelname() As String
labelname = c_name
End Property
Public Property Let labelname(ByVal name As String)
c_name = name
End Property
//form
Public Sub Command1_Click()
Label1.labelname = "john"
End Sub
-
labelname is not a method of Label1. You need do dim a variable with your class that you created and then access the labelname.
Code:
Public Sub Command1_Click()
Dim MyClass As New yourclassname
MyClass.labelname = "john"
End Sub
-
I think you need to link to the class.
In form:
Private WithEvents m_Label As clsLabel
Set m_Label = New clsLabel
Call m_Label.LinkClassToForm(Me)
In class:
Private WithEvents m_ParentForm As Form
Public Sub LinkClassToForm(ByRef i_Form As Form)
Set m_Form = i_Form
Set m_Label = m_ParentForm.Label
End Sub
Or something like that as a starter!
:D