Error assigning textbox object to class property - xl2007

kkatzer

New Member
Joined
Nov 12, 2009
Messages
5
Hello,

I am getting a type mismatch "Run-time error '13'" when I try to assign a textbox to a property of a class object which is defined as textbox. I do the same thing for combobox and button controls with no problem.

The class "clsSessionTextBox" is like:
------------------------
Public strMillName As String
Public strControlName As String
Public ctlTextBox As TextBox

------------------------

The following is extracted from the function where I am getting the error:

Dim clsTxt As clsSessionTextBox
Set clsTxt = New clsSessionTextBox

Set clsTxt.ctlTextBox = txtSessionIDArc <--- this throws the error
-------------------------

txtSessionIDArc exists and is a valid textbox.

[txtSessionIDArc TextBox (properties definition)]

As I mentioned earlier, I do the same type of things for comboboxes and commandbuttons and they process just fine. The class seems defined correctly to me. I have thrown another textbox on the sheet and plugged it into the code just to see if there was something odd about the other textbox control but the result is the same.

I have tried as many variations as I can think of and searched for posts with similar problems but I cannot find a solution.

Oh, this is an Excel 2003 workbook that is now being modified in Excel 2007. It was working fine until I entered the code to assign the textbox.

I am trying to build a collection of classes. I usually play in .Net land so Excel VBA is foreign enough to me to make me scratch my head now and again.

Thanks much,

Kim
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
Thanks to everyone who viewed this and may have been attempting to provide me with a solution.

I asked the question a different way and finally found a post (on this forum through Google).

User 'tusharm' had provided the solution in 2003.

I was setting the class property to the type 'Textbox' and should have been setting the property to type 'msforms.TextBox'.

Thanks tusharm.
 
Upvote 0
Glad you found a solution. I had been looking at it, but object oriented programming is not my strong point ;). So couldn't help...
Then I saw your post pop up again, so thought I d have another look.
 
Upvote 0

Forum statistics

Threads
1,221,310
Messages
6,159,176
Members
451,543
Latest member
cesymcox

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