|
-
Mar 27th, 2000, 10:09 PM
#1
Thread Starter
New Member
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
-
Mar 27th, 2000, 10:16 PM
#2
Lively Member
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
-
Mar 27th, 2000, 10:21 PM
#3
Fanatic Member
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!

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
|