Results 1 to 3 of 3

Thread: setting a property's value

  1. #1

    Thread Starter
    New Member
    Join Date
    Mar 2000
    Posts
    5
    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

  2. #2
    Lively Member
    Join Date
    Jan 2000
    Location
    Springfield, IL
    Posts
    124
    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

  3. #3
    Fanatic Member Bonker Gudd's Avatar
    Join Date
    Mar 2000
    Location
    Saturn
    Posts
    748
    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
  •  



Click Here to Expand Forum to Full Width