+ Reply to Thread
Results 1 to 3 of 3

Passing Custom Class Variables through Functions

  1. #1
    Registered User
    Join Date
    02-15-2006
    Posts
    18

    Passing Custom Class Variables through Functions

    I am trying to pass a custom class through a function, I can watch the variable, it gets passed to the function but when it goes to be returned I get this error,
    Object doesn't support this property or method (Error 438)
    Am I doing the syntax wrong or something, here is the function.
    Function ChangeOffSet(SSheet As SSched)
    ' This Sets the Offset of the Variables
    If (SSheet.WorkMonth + SSheet.DaysOn) - SSheet.DaysOff < 0 Then
    SSheet.WorkMonth = (SSheet.WorkMonth + SSheet.DaysOn)
    Else
    SSheet.WorkMonth = SSheet.WorkMonth + (SSheet.DaysOn)
    End If

    ChangeOffSet = SSheet
    End Function
    When I call it It looks like this
    I use the same variable names.
    SSheet = ChangeOffSet(SSheet)
    Thanks a bunch

  2. #2
    Andy Pope
    Guest

    Re: Passing Custom Class Variables through Functions

    Hi,

    As it is an object you need to use the Set command.

    Set SSheet = ChangeOffSet(SSheet)

    and in the function

    set ChangeOffSet = SSheet

    Cheers
    Andy

    Xiazer wrote:
    > I am trying to pass a custom class through a function, I can watch the
    > variable, it gets passed to the function but when it goes to be
    > returned I get this error,
    > *Object doesn't support this property or method (Error
    > 438)*
    > Am I doing the syntax wrong or something, here is the function.
    > Function ChangeOffSet(SSheet As SSched)
    > ' This Sets the Offset of the Variables
    > If (SSheet.WorkMonth + SSheet.DaysOn) -
    > SSheet.DaysOff < 0 Then
    > SSheet.WorkMonth = (SSheet.WorkMonth +
    > SSheet.DaysOn)
    > Else
    > SSheet.WorkMonth = SSheet.WorkMonth +
    > (SSheet.DaysOn)
    > End If
    >
    > ChangeOffSet = SSheet
    >
    > End Function
    >
    > When I call it It looks like this
    > I use the same variable names.
    > *SSheet = ChangeOffSet(SSheet)*
    >
    > Thanks a bunch
    >
    >


    --

    Andy Pope, Microsoft MVP - Excel
    http://www.andypope.info

  3. #3
    Registered User
    Join Date
    02-15-2006
    Posts
    18
    Thanks Andy, your my hero!

+ 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