Can I use a Frame in UserForm as parameter of my function?

J

Jing You

hi,

I want to use a frame in UserForm as parameter of a function like this:

Private Sub ShowFrame(ByRef F As MSForms.Frame)
F.Top = 10
End Sub

But when I call this procedure using the code:

ShowFrame(BasicFrame) 'BasicFrame is a Frame in UserForm

the compiler throws an exception to tell me the BasicFrame's type is
invalid.

Then I have tested several different type, like this:

Private Sub ShowFrame(ByRef F As Frame)
F.Top = 10
End Sub

Private Sub ShowFrame(ByRef F As Control)
F.Top = 10
End Sub

And they all doesn't work. What's wrong with the code?


Thanks,
Jing You
 
H

Helmut Weber

Hi Jing,
it is the way you are calling your sub.
Use either
call ShowFrame(BasicFrame)
or
ShowFrame BasicFrame
 
J

Jing You

hi, Helmut

My VB IDE can correct the code to the format you said, but it can not solve
my problem.

The key of the problem is what is the real type of a frame in UserForm. I
have viewed the Object browser in VBA to find the content of MSForms.Frame,
The property Top and Left which we can find in Property Inspector of frame
in UserForm are not MSForms.Frame's property. So, can we say the frame in
UserForm is not a MSForms.Frame?

How to solve the problem?

Thanks,
Jing You
 

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