creating an object of a form at runtime using its name as string
-
Hi There is a form named "Form1" and a function for creating its object. the form name is passed to the function and creates an object public function CreateObj(p_sformName as string) as object dim obj as object ' create the object of a form. The form's name is passed from the calling place set obj = new p_sformname end sub Is it possible Thank you in advance Panal prasad
-
Hi There is a form named "Form1" and a function for creating its object. the form name is passed to the function and creates an object public function CreateObj(p_sformName as string) as object dim obj as object ' create the object of a form. The form's name is passed from the calling place set obj = new p_sformname end sub Is it possible Thank you in advance Panal prasad
panalprasad wrote: set obj = new p_sformname the syntax is incorrect. as you wrote it, you try to new an object which type is p_sformName. replace it with
obj = new String(p_sformname)
this will create a new string which content is identical to the parameter passed to the CreateObj() function. now, if you want to create an object with another type than String, you must use a constructor that gets a String as parameter ; if it doesn't exist, you'll have to create it certainly... but i cannot help you more as your post is a bit too vague for me to know what you're looking for exactly
TOXCCT >>> GEII power
[toxcct][VisualCalc] -
panalprasad wrote: set obj = new p_sformname the syntax is incorrect. as you wrote it, you try to new an object which type is p_sformName. replace it with
obj = new String(p_sformname)
this will create a new string which content is identical to the parameter passed to the CreateObj() function. now, if you want to create an object with another type than String, you must use a constructor that gets a String as parameter ; if it doesn't exist, you'll have to create it certainly... but i cannot help you more as your post is a bit too vague for me to know what you're looking for exactly
TOXCCT >>> GEII power
[toxcct][VisualCalc]The obj variable is needed for seting the form object. and the name of the form is p_sformname. so if p_sformname="Form1" then obj will assaign an object of Form1
-
Hi There is a form named "Form1" and a function for creating its object. the form name is passed to the function and creates an object public function CreateObj(p_sformName as string) as object dim obj as object ' create the object of a form. The form's name is passed from the calling place set obj = new p_sformname end sub Is it possible Thank you in advance Panal prasad
By your use of the
Set
statement, I take it your using VB6. VB6 can't do what you want. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome