[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

VB 4.0 How to load a form by VarName

Posted on 1998-12-10
5
Medium Priority
?
144 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

What’s Wrong with Your Cloud Strategy ?

Even as many CIOs are embracing a cloud-first strategy, the reality is that moving to the cloud is a lengthy process and the end-state is likely to be a blend of multiple clouds—public and private. Learn why multicloud solutions matter in this webinar by Nimble Storage.

Question has a verified solution.

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

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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 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…
Suggested Courses

650 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