Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How To Load Form Using String Variable
Message
 
To
17/10/1997 23:02:55
General information
Forum:
Visual Basic
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00055256
Message ID:
00055558
Views:
28
This question came up on the UT about 2-3 months ago... the short answer is that it cannot be done directly... if you are certain that the form exists with the name you've specified... then you can do a Select Case statement to make it work...

Select Case sFormName
Case "Form1"
Form1.Show
Case "Form2"
Form2.Show
End Select

...since the VB Forms collection only has the loaded forms you can't loop thru looking for the form
which has the name property equal to your string, unless you know the form is already loaded...

(of course, saying IT CAN'T BE DONE is almost a guarantee someone will prove me wrong)

Stan B.


>>In Form2, create a command button called Command1.
>>For command button Command1 On Click Event, I've typed in the following statement:
>>
>>Dim frm1 as string
>>
>>frm1 = "Form1"
>>load frm1
>>
>>Then when I run the Form2 and click on command button Command1, error message appear.
>
>If you call it like this, my guess would be that a frm1 has to exist, which is why it is returning an error. What you want here it to load the form Form1 which is contained in the variable frm1. Maybe someone who knows the exact syntax will be able to help you.
>
>In Visual FoxPro, we would use the (frm1) syntax for that. I am not sure about Visual Basic.
Previous
Reply
Map
View

Click here to load this message in the networking platform