Friday, August 10, 2007

Strange bug(?) - Pass Me as a parameter works...sometimes

When I try to pass Me (As Variant) into a method that takes one parameter (getHåndbok in the pic), it works, when I try to pass Me into a sub that takes three parameters(getUtsnitt in the pic), this happens:
Error

I have to create a variant and assign Me to it to make it work (replace Me with obj). Bug?

The Subs being called:



2 comments:

Dwight Wilbanks said...

I assume you are within a class.

I've never had issues with using the Me keyword. When I'm passing outside the class, I usually use "this" which is just a regular variable name and not reserved.

This the syntax that I use.

Class Test
 Function FuncA(A As Test)
  Call Me.SubA(Me)
  Call Test_SubB(Me)
 End Function
 Sub SubA(A As Test)
  Call Me.FuncA(Me)
  Call Test_FuncB(Me)
 End Sub
End Class
Function Test_FuncB(This As Test)
 Call This.SubA(This)
 Call Test_SubB(This)
End Function
Sub Test_SubB(This As Test)
 Call This.FuncA(This)
 Call Test_FuncB(This)
End Sub

I rarely need to use variants for this type of thing.

Can you reproduce the problem?

Unknown said...

The reason that I use a variant is this: I walk through a structure made up from documents of two types, menuitem-/content-documents.

I can't get the structure from a view without cross-storing values, which I'm not fond of.

On every node, I call a method on the object being passed, obj.nextNode( entry ).

I could just gather the entries in a list, but then I'd had to do two loops, one to make the list, and one to process the structure.

===================

I did a quick test.

With a string as the first parameter, everything OK!

With a NotesView as the first Parameter:

---------------------------
IBM Lotus Domino Designer
---------------------------
Data not saved due to script error(s)
---------------------------
OK
---------------------------


Code used:
Class PassMeAsVariant
Private one As NotesView

Sub New
Call takeOne( Me )
Call takeThree( one, 2, Me )
End Sub
End Class

'methods:
Sub takeOne( var As Variant )

End Sub

Sub takeThree( view As NotesView, dbfl As Double, var As Variant )

End Sub