Problem passing argument and then assessing it

R

red6000

Hi I have a sub with 1 argument which is a userform, I then want to perform
a task dependent on which userform was passed:

Sub decide (xForm as UserForm)

Dim frm As UserForm
Set frm = xForm

If frm = UserForm1 Then
Selection.TypeText Text:= Chooser.textbox1.text
Selection.TypeText Text:= frm.textbox1.text
Else
Selection.TypeText Text:= Chooser.textbox2.text
Selection.TypeText Text:= frm.textbox1.text
End If

My code fails on the 'if' line with teh error 'mismatch'. Any ideas what
I'm doing wrong?

Thanks.
 
H

Helmut Weber

Hi,

Sub decide(xForm As UserForm)
If xForm Is UserForm1 Then
Selection.TypeText "yes"
Else
Selection.TypeText "no"
End If
End Sub

' ---------------------------

Sub TestXX()
decide UserForm2
End Sub

Don't know, what that would be good for.

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top