Solved

VB 4.0 How to load a form by VarName

Posted on 1998-12-10
5
136 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 20 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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

717 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