Passing WebListBox into a method as argument

I have a WebPage and a WebContainer. I created a WebPage method where I am passing in a WebListBox object from the WebContainer as an argument. Inside that method, I am trying to call a method of the passed in WebListBox, but I am getting the following error (does not compile):

There is more than method with this name but this does not match any of the available signatures.

This is the line of code causing the error:

MyListBox.CellTextAt(row1Index, lbCol) = MyListBox.CellTextAt(row2Index, lbCol)

Any ideas why I am getting this error?.

How do you pass the WebListBox to the method ?

I call the method in the Press event of a button in the WebContainer. For example:

MyWebPage.MyMethod(MyWebListBox)

I thought it might be because the WebListBox isn’t passed in ByRef by default and instead ByVal, so I tried stating ByRef in the Method declaration, but that didn’t work.

The method declaration is like:

MyMethod(lb As WebListBox)

When you’re getting the CellTextAt value, it will return a Variant. Try this instead:

MyListBox.CellTextAt(row1Index, lbCol) = MyListBox.CellTextAt(row2Index, lbCol).StringValue
2 Likes

Why do you use MyWebListBox inside your method, instead of lb ?

Should it not be

Lb.CellTextAt(row1Index, lbCol) = Lb.CellTextAt(row2Index, lbCol)
1 Like

Thanks, this now worked perfectly! I didn’t realise a CellTextAt returns a Variant (perhaps because the name to me suggests a String)

2 Likes

Yes you’re right. That was a typo here (and not in my code) when trying to simplify the problem.

I agree with you that it should be called CellValueAt

1 Like