Can't assign a textbox to object

G

Guest

Running vb6 in xl2000.

I can't assign a textbox to a textbox object. Why not?

Assume that TextBox1 and CommandButton1 are defined on some form, or
worksheet, then this works:

Dim cb As CommandButton
Set cb = CommandButton1

But this fails with a type mismatch:

Dim tb As TextBox
Set tb = TextBox1

I seems that TextBox1 does not refer to the TextBox as a whole, but to the
text that it contains, i.e. TextBox1.Text.
 
D

Dave Peterson

There's a textbox in the Drawing toolbar, too.

You'll want to be specific about which type you want to use:

Dim tb As msforms.TextBox

there's only one commandbutton, but this wouldn't hurt:
dim cb as msforms.commandbutton

And might remind you why you did things that way.
 
G

Guest

Dave,
Many thanks -- that's solved it.
colin..

Dave Peterson said:
There's a textbox in the Drawing toolbar, too.

You'll want to be specific about which type you want to use:

Dim tb As msforms.TextBox

there's only one commandbutton, but this wouldn't hurt:
dim cb as msforms.commandbutton

And might remind you why you did things that way.
 

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