Loading a Visual Basic Form using a String VAR 
Author Message
 Loading a Visual Basic Form using a String VAR

Can anyone help me?

I have an array of form names which during the operation of an application,
the user would move through a series of steps (the forms).

I cannot seem to evaluate the contents of the string so that I can the name
to enable me to display the form on the screen:

Dim strFormNames(10)

StrFormNames(1) = "frmFirstForm"
StrFormNames(2) = "frmSecondForm"
StrFormNames(3) = "frmThirdForm"

I have tried:

 Dim objFormName as Form
 Set objFormName = strFormNames(1)

 objFormName.Show

 ......  This causes an error.

How do I use the contents of the string, so that I can show the form???

Please help!!!




Thu, 09 Mar 2000 03:00:00 GMT  
 Loading a Visual Basic Form using a String VAR

: I cannot seem to evaluate the contents of the string so that I can the
name
: to enable me to display the form on the screen:
:
: Dim strFormNames(10)
:
: StrFormNames(1) = "frmFirstForm"
: StrFormNames(2) = "frmSecondForm"
: StrFormNames(3) = "frmThirdForm"

frm2Show = StrFormNames(1)

Select case frm2Show

     case StrFormNames(1)
        frmFirstForm.show
     case StrFormNames(2)
        frmSecondForm.show

 ...etc.

I'm totally amazed at the number of programmers wanting to pass form names
as strings, and expecting that VB should know when to treat the same thing
as both a string value and an object.

--
Randy Birch, MVP Visual Basic

Moderator, Fidonet Visual Basic Programmer's Conference
VBnet, The Visual Basic Developers Resource Centre
http://home.sprynet.com/sprynet/rasanen/



: Can anyone help me?
:
: I have an array of form names which during the operation of an
application,
: the user would move through a series of steps (the forms).
:
: I cannot seem to evaluate the contents of the string so that I can the
name
: to enable me to display the form on the screen:
:
: Dim strFormNames(10)
:
: StrFormNames(1) = "frmFirstForm"
: StrFormNames(2) = "frmSecondForm"
: StrFormNames(3) = "frmThirdForm"
:
:
: I have tried:
:
:  Dim objFormName as Form
:  Set objFormName = strFormNames(1)
:
:  objFormName.Show
:
:  ......  This causes an error.
:
: How do I use the contents of the string, so that I can show the form???
:
: Please help!!!
:
:

:
:
:



Thu, 09 Mar 2000 03:00:00 GMT  
 Loading a Visual Basic Form using a String VAR

Hello Robert

You can't do what you want to do in Visual Basic.  Not exactly anyway.
what you could do is:

Private MyForms as collection

Myforms.Add Key:=frmFirstForm.Name, Item:=frmFirstForm
Myforms.Add Key:=frmSecondForm.Name, Item:=frmSecondForm
Myforms.Add Key:=frmThirdForm.Name, Item:=frmThirdForm

Then you can do something like:

Dim AForm as Form
Set AForm = MyForms(frmFirstForm.Name)
Aform.Show

Hope that helps you do what you want to do.  But it would perhaps be better
if you gave up those old FoxPro ways and did things differently :-D
--
Ibrahim
A MS Developer MVP
====================
Malluf Consulting Services

http://www.*-*-*.com/
===================================
Check out the latest ViewSource column:
http://www.*-*-*.com/
===================================
My {*filter*}: http://www.*-*-*.com/



Quote:
> Can anyone help me?

> I have an array of form names which during the operation of an
application,
> the user would move through a series of steps (the forms).

> I cannot seem to evaluate the contents of the string so that I can the
name
> to enable me to display the form on the screen:

> Dim strFormNames(10)

> StrFormNames(1) = "frmFirstForm"
> StrFormNames(2) = "frmSecondForm"
> StrFormNames(3) = "frmThirdForm"

> I have tried:

>  Dim objFormName as Form
>  Set objFormName = strFormNames(1)

>  objFormName.Show

>  ......  This causes an error.

> How do I use the contents of the string, so that I can show the form???

> Please help!!!





Thu, 09 Mar 2000 03:00:00 GMT  
 Loading a Visual Basic Form using a String VAR

Ibrahim,

You must be very familiar with FoxPro if you know macro sub....
Rather an odd admission for a VB guy <bg>

As one moving from VFP to VB, I'm very happy with VB except inheritance.
After all, VC++, VJ, and VFP all support it.  Life (at work) would be much
better if only...
Then again, I did stop using VFP, except for OLE data servers.

BTW, thanks for all your time spent in the CServe forums.

Greg Longtin


Quote:
> Clip
>Hope that helps you do what you want to do.  But it would perhaps be better
>if you gave up those old FoxPro ways and did things differently :-D
>--
>Ibrahim
>A MS Developer MVP
>====================
>Malluf Consulting Services

> http://www.*-*-*.com/
>===================================
>Check out the latest ViewSource column:
> http://www.*-*-*.com/
>===================================
>My {*filter*}: http://www.*-*-*.com/



Sat, 11 Mar 2000 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Loading a Visual Basic Form using a String VAR

2. Loading a VB form when the name is stored in a String VAR

3. Loading a VB form when the name is stored in a String VAR

4. Loading a VB form when the name is stored in a String VAR

5. how to load a txt file in a string in visual basic

6. loading visual basic 3.0 applications in visual basic 5.0

7. Need to load a form using string variable as reference

8. Hiow to Load a form using a string variable

9. How to Load a form using String variables

10. Visual Basic 5 Form Loading

11. Loading and unloading DLLs using Visual Basic

12. Avoiding load of 32-bit custom control using 16-bit Visual Basic 4.0

 

 
Powered by phpBB® Forum Software