+ Reply to Thread
Results 1 to 3 of 3

Objects as arguments to Sub

  1. #1
    Registered User
    Join Date
    06-21-2010
    Location
    Gothenburg
    MS-Off Ver
    Excel 2003
    Posts
    50

    Objects as arguments to Sub

    Hello everyone

    This should be a fairly basic and commonly asked question and I've searched both the web and here for a solution but have yet to find one.

    What I want to do is create a Sub that takes an object ByRef.

    This is my code

    DateForm:
    Please Login or Register  to view this content.
    Here is where it's used:

    Please Login or Register  to view this content.
    I have also tried:

    Please Login or Register  to view this content.
    I get an Error 424 Object required in both cases. I suspect the error occurs because I send a copy instead of a ref or something like that but I really can't figure it out. I also tried using ByVal (which shouldn't really work) but I get the same error.

    I get the error on this line:
    DateForm.DisplayDateForm (DateBox)
    i.e. when I call the function.

    Thanks in advance
    Last edited by Brunstgnegg; 07-01-2010 at 03:17 AM.

  2. #2
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Objects as arguments to Sub

    Remove the parentheses round the object when you pass it to the sub:
    Please Login or Register  to view this content.
    Remember what the dormouse said
    Feed your head

  3. #3
    Registered User
    Join Date
    06-21-2010
    Location
    Gothenburg
    MS-Off Ver
    Excel 2003
    Posts
    50

    Re: Objects as arguments to Sub

    *Smacks forehead*

    Thanks

    Move along people nothing to see here
    Last edited by shg; 07-01-2010 at 11:17 AM. Reason: deleted quote

+ 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