passing object to a subroutine

nobenbien

New Member
Joined
Jul 25, 2011
Messages
4
Hello,

I'm struggling with the next problem:

I made a Userform containing a textbox (textbox1) and Clickbutton.

I also created a classmodule (named checkinput).
This classmodule contains a subroutine Ispresent:

Sub ispresent(ByVal textbox As Msforms.textbox)
'code goes here
End Sub

The code for the userform contains a subroutine CommandButton1_Click:

Dim input As New checkinput
Private Sub CommandButton1_Click()
input.ispresent (textbox1)
End Sub

When i try to run the program i get an error message Error 424, Object required.

I don't know how to solve this problem.
Can anyone help me out.

Thx
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
Just thinking out loud... can you pass an object by value? I thought you could only pass them by reference.

I've no idea why I thought that though... :confused:
 
Last edited:
Upvote 0
Yes, you can - look at any event routine that provides you with an object argument.
 
Upvote 0
Oh yes... Microsoft must have changed that this morning! :)
 
Upvote 0
If you pass an object ByVal, you pass a copy of the pointer to the object (not a copy of the object itself), so you can alter the object but you can't change what the pointer points at.
 
Upvote 0

Forum statistics

Threads
1,224,583
Messages
6,179,673
Members
452,937
Latest member
Bhg1984

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top