+ Reply to Thread
Results 1 to 3 of 3

Userform level class instance doesn't recognize methods

  1. #1
    =Ray=
    Guest

    Userform level class instance doesn't recognize methods

    Hello,

    I have a class (csList) with several properties and methods and I need to
    have it "publicly" available within the routines of a userform. When I use
    "Public|Private ls As New csList" at the top of the userform code and
    reference the methods in any of the userform routines as "ls.method" it tells
    me Method or Data Member not found (Autocompletion doesn't recognize them
    either). I've also tried removing the New statement and using a "Set ls = New
    csList" line in the userform code, but the same thing happened.

    What am I doing wrong?
    Thanks,
    =Ray=

  2. #2
    Peter T
    Guest

    Re: Userform level class instance doesn't recognize methods

    Hi Ray,

    With the following everything works as expected, including the intellisense

    ' code userform1
    Private ls As New csList

    Private Sub UserForm_Click()
    MsgBox ls.propFlag
    Me.Caption = ls.fncTest
    End Sub

    Private Sub UserForm_Initialize()
    ls.propFlag = True
    End Sub

    ' code in csList
    Dim bFlag As Boolean

    Public Property Let propFlag(b As Boolean)
    bFlag = b
    End Property

    Public Property Get propFlag() As Boolean
    propFlag = bFlag
    End Property

    Public Function fncTest() As String
    fncTest = CStr(bFlag)
    End Function

    Run the form and click on it

    (first letter in "ls" is lower case L, not an upper i or number one, which I
    first suspected might be the problem)

    Regards,
    Peter T


    "=Ray=" <[email protected]> wrote in message
    news:[email protected]...
    > Hello,
    >
    > I have a class (csList) with several properties and methods and I need to
    > have it "publicly" available within the routines of a userform. When I use
    > "Public|Private ls As New csList" at the top of the userform code and
    > reference the methods in any of the userform routines as "ls.method" it

    tells
    > me Method or Data Member not found (Autocompletion doesn't recognize them
    > either). I've also tried removing the New statement and using a "Set ls =

    New
    > csList" line in the userform code, but the same thing happened.
    >
    > What am I doing wrong?
    > Thanks,
    > =Ray=




  3. #3
    =Ray=
    Guest

    Re: Userform level class instance doesn't recognize methods

    Thank you for your effort.

    Silly me, all my class routines were private! (I taught myself VBA a few
    years ago, and I haven't done much with it since then, and I guess I've
    gotten rusty!)

    =Ray=

    "Peter T" wrote:

    > Hi Ray,
    >
    > With the following everything works as expected, including the intellisense
    >
    > ' code userform1
    > Private ls As New csList
    >
    > Private Sub UserForm_Click()
    > MsgBox ls.propFlag
    > Me.Caption = ls.fncTest
    > End Sub
    >
    > Private Sub UserForm_Initialize()
    > ls.propFlag = True
    > End Sub
    >
    > ' code in csList
    > Dim bFlag As Boolean
    >
    > Public Property Let propFlag(b As Boolean)
    > bFlag = b
    > End Property
    >
    > Public Property Get propFlag() As Boolean
    > propFlag = bFlag
    > End Property
    >
    > Public Function fncTest() As String
    > fncTest = CStr(bFlag)
    > End Function
    >
    > Run the form and click on it
    >
    > (first letter in "ls" is lower case L, not an upper i or number one, which I
    > first suspected might be the problem)
    >
    > Regards,
    > Peter T
    >
    >
    > "=Ray=" <[email protected]> wrote in message
    > news:[email protected]...
    > > Hello,
    > >
    > > I have a class (csList) with several properties and methods and I need to
    > > have it "publicly" available within the routines of a userform. When I use
    > > "Public|Private ls As New csList" at the top of the userform code and
    > > reference the methods in any of the userform routines as "ls.method" it

    > tells
    > > me Method or Data Member not found (Autocompletion doesn't recognize them
    > > either). I've also tried removing the New statement and using a "Set ls =

    > New
    > > csList" line in the userform code, but the same thing happened.
    > >
    > > What am I doing wrong?
    > > Thanks,
    > > =Ray=

    >
    >
    >


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1