2

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?

4

1 回答 1

4

它不是CallByName

TestFkt Form1, Me

也无效,因为Me使用ParamArray. 这是一个特殊的Me情况。

解决方法:

Dim fMe As VB.Form: Set fMe = Me
CallByName Form1, "TestFkt", VbMethod, fMe, Command1
于 2014-02-06T16:12:42.353 回答