Solved

Show statement

Posted on 1999-01-04
8
139 Views
Last Modified: 2010-05-03
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
0
Comment
Question by:hpet
  • 3
  • 3
  • 2
8 Comments
 
LVL 13

Accepted Solution

by:
Mirkwood earned 50 total points
ID: 1453753
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
 
LVL 1

Author Comment

by:hpet
ID: 1453754
no "work arround" at all?
nothing at all?
how about object declered as form and then using new statement?

Peter

0
 
LVL 15

Expert Comment

by:ameba
ID: 1453755
VB6 makes this possible. It has function CallByName
0
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 
LVL 15

Expert Comment

by:ameba
ID: 1453756
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
 
LVL 13

Expert Comment

by:Mirkwood
ID: 1453757
I thought that it was only possible in VBA?
But can you create another instance of the same form using the same method?
0
 
LVL 1

Author Comment

by:hpet
ID: 1453758
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
 
LVL 15

Expert Comment

by:ameba
ID: 1453759
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
 
LVL 1

Author Comment

by:hpet
ID: 1453760
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

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
vb6 programatically bring window to front 8 70
Problem to skip loop 6 57
Copy a row 12 61
VBA: Personal Macro Retain/Highlight/Remove values in a selected column 4 30
There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

786 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question