?
Solved

VB 4.0 How to load a form by VarName

Posted on 1998-12-10
5
Medium Priority
?
139 Views
Last Modified: 2011-09-20
I want to read the name of the last loaded form out or a .ini-file. Then I want to load the form.

For example:
the last form was 'frmTest'. I read the name into gsForm.
Now I want to load the form 'frmText'.

I can't use the code
 For x = 0 to Forms.Count-1
    ...
 Next x

because it only works with the forms already loaded.
What's to do?
0
Comment
Question by:koz2355
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 10

Expert Comment

by:caraf_g
ID: 1449256
Before I can answer your question, I would like to have a bit more information.

1 - Do you refer to your form frmTest by its design time name?
    for example
    frmTest.Show vbModal
2 - Do you instantiate your form through object variables?
    for example
    Dim myForm As frmTest
    Set myForm = New frmTest
    myForm.Show vbModal
3 - Do you wish to re-display a form with its old contents or do you intend to create a new instance of the form?


0
 

Author Comment

by:koz2355
ID: 1449257
Hi caraf_g,

frmTest was an example. the formname could be any form in my application the user can work with. For better understanding:
dim gsForm as string
gsForm = "frmTest"
gsForm.Show <- something like this

greetings
0
 
LVL 13

Expert Comment

by:Mirkwood
ID: 1449258
Sorry, not possible. The only thing that you can do is have an switch statement and test on the name and make an instance of this form.
0
 
LVL 10

Accepted Solution

by:
caraf_g earned 60 total points
ID: 1449259
Having only used VB5 myself I can't guarantee that the following will work. I hope it is possible in VB4 to Dim variables As Object, and that you can use the Set keyword in VB4.

If you can, this might work for you:

Dim gobjForm As Object
Dim gsForm As String

Select Case gsForm
Case "frmTest"
    Set gobjForm = New frmTest
Case "<other form>"
    Set gobjForm =.... and so on
.
End Select

All the best, and good luck
0
 

Author Comment

by:koz2355
ID: 1449260
Hi caraf_g,
it works. Thank you very much.
greetings
koz2355
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…
Suggested Courses
Course of the Month13 days, 19 hours left to enroll

801 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