Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Type Mismatch Error

Status
Not open for further replies.

huBBLe

Programmer
May 15, 2001
50
SG
I have a method in a bas module:

**********************************************
Public Sub clearForm(theForm As Form)
Dim ctlC As Control

For Each ctlC In theForm.Controls
If TypeOf ctlC Is TextBox Then ctlC.Text = ""
If TypeOf ctlC Is ComboBox Then ctlC.Clear
If TypeOf ctlC Is CheckBox Then ctlC.Value = 0
If TypeOf ctlC Is OptionButton Then ctlC.Value = False
Next

End Sub
**********************************************

from a form, i tried to call this method by

**********************************************
Private Sub mnuFileNew_Click()
Dim result as Integer
result = MsgBox "Clear?"
If result = vbYes Then clearForm (Me)
End Sub
**********************************************

when i try to run, the program gives me a "type mismatch" error.

can someone tell me what is wrong?

Thanks a million!
 
Dim result As Integer

result = MsgBox("Clear?")
If result Then clearForm Me

You had () around your argument indicating that it returned a value, the code above will work
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top