Show statement

Hi,

I have a toolbar control and each of buttons on it cary some information. For example Button(1).Key caries information which form to show when you press it.
Now i am having difficulties on how to make it work with show statement.

like: <button.key>.show

how could i make it work?

thanks,
Peter
LVL 1
hpetAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
MirkwoodConnect With a Mentor Commented:
I'm sorry
The only way to do it is using a select statement

select case button.key
 case "myform1":
       myform1.show
 case "myform2":
       myform2.show
end select
0
 
hpetAuthor Commented:
no "work arround" at all?
nothing at all?
how about object declered as form and then using new statement?

Peter

0
 
amebaCommented:
VB6 makes this possible. It has function CallByName
0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

 
amebaCommented:
Well, I tried this in IDE. It worked
    Dim x As Form
    Set x = Forms.Add("Form2")
    x.Show

Perhaps, you can use this:

Private Function ShowAForm(FormName As String) As Form
    Set ShowAForm = Forms.Add(FormName)
    ShowAForm.Show
End Function

' usage in your Toolbar_Click
    ShowAForm(button.key)
0
 
MirkwoodCommented:
I thought that it was only possible in VBA?
But can you create another instance of the same form using the same method?
0
 
hpetAuthor Commented:
Thanks Ameba. It's working ok.
Thank for trying Mirkwood.
btw, i tried and it is possible to create multiple instances of same form using same method.

Thanks,
Peter

0
 
amebaCommented:
hpet, before you go too far using Forms.Add

It is confirmed VB6 bug. I thought it doesn't work compiled to native code in VB6.
But it also doesn't work compiled to p-code. The same is in VB5.
0
 
hpetAuthor Commented:
Thanks for warning. I almost did go too far with it.
Anyway i didn't plan to use it much so i can wait with it.
I just hope this wont be one more bug that will drag along versions like some others...

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.