Results 1 to 6 of 6

Thread: [RESOLVED] CallByName

  1. #1

    Thread Starter
    PowerPoster gavio's Avatar
    Join Date
    Feb 2006
    Location
    GMT+1
    Posts
    4,462

    Resolved [RESOLVED] CallByName

    I have:

    - Form1
    - Class1 (with method Test)

    In Form1, i have declared:
    Code:
    Private x As Class1
    Now, i want to use CallByName from another module, to call Test from Class1. E.g.:
    Code:
    CallByName Form1, "x.Test", vbMethod
    But it doesn't go that easy Is there any solution to my problem?

    Thanx!

    -gav

  2. #2
    VB6, XHTML & CSS hobbyist Merri's Avatar
    Join Date
    Oct 2002
    Location
    Finland
    Posts
    6,654

    Re: CallByName

    Code:
    Public X As Class1
    Code:
    CallByName Form1.X, "Test", vbMethod
    Remember to initialize X before calling CallByName.

  3. #3

  4. #4
    VB6, XHTML & CSS hobbyist Merri's Avatar
    Join Date
    Oct 2002
    Location
    Finland
    Posts
    6,654

    Re: CallByName

    Besides dirty hacking that involves extra coding, thus not being not really worth it, no. CallByName can't call Private features because it can't see them because they are, you guessed it, private. And thus hidden. You can't call what you can't see.

  5. #5
    PowerPoster
    Join Date
    Jan 2008
    Posts
    11,074

    Re: CallByName

    Quote Originally Posted by Merri
    Besides dirty hacking that involves extra coding, thus not being not really worth it, no. CallByName can't call Private features because it can't see them because they are, you guessed it, private. And thus hidden. You can't call what you can't see.
    If you have a private function and a regular call to that function in the same module then you can call that private function. But if you have a private function and a CallByName in the same module you cannot call that function so it appears that the reason goes beyond the mear fact that it is a private function.

  6. #6

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