View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Goofy Goofy is offline
external usenet poster
 
Posts: 54
Default Passing a Control as an Argument

Type mismatch .....


....Calling Form.......
Private Sub CommandButton1_Click()
Dim c1 As New Class1

c1.addStuff (Label1)

End Sub


in class1 . . . . . . . . .

Public Sub addStuff(ByRef myLabel As MSForms.Label)

myLabel.Caption = "Stuff"

End Sub



"Andy Pope" wrote in message
...
Hi,


If by form you mean userform then the object type would be MSForms.Label

Cheers
Andy

Goofy wrote:
Hi,

I have a form with a label control on it. I want to pass this as an
argument to a function which does a test. The problem is that this gives
me a type mismatch on this form which calls it. If you hover the mouse
cursor over the argument which is passed to the function from the calling
method in the form, it returns a string value.

Any IDeas ?

Public Function MyFunction( myLabel as Label ) As Boolean

myLabel.Caption = "SomeString"

MyFunction = True

End Function




--

Andy Pope, Microsoft MVP - Excel
http://www.andypope.info