Question

I want to pass the sourceform, from which I use the CallByName-function. Somehow, it doesn't work in way I post it down there.

Private Sub Command1_Click()
  'CallByName Form1, "TestFkt", VbMethod, Nothing, Command1   '<--- works
  CallByName Form1, "TestFkt", VbMethod, Me, Command1         '<--- Problem
End Sub

Public Function TestFkt(ParamArray myParams())
  Dim oForm As Object
  Set oForm = myParams(0)

  ' ...
End Function

The error reported from vb6 is runtime error 450: "Falsche Anzahl an Argumenten oder ungültige Zuweisung zu einer Eigenschaft". I think the first reason is not the problem, because the commented line above works. It seems more, that the problem has something to do with the keyword me.

Anybody some idea?

Was it helpful?

Solution

Its not CallByName:

TestFkt Form1, Me

Is also not valid as you cannot pass Me when using a ParamArray. This is a peculiarity of Me which is something of a special case.

Workaround:

Dim fMe As VB.Form: Set fMe = Me
CallByName Form1, "TestFkt", VbMethod, fMe, Command1
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top