Jul 20, 2004 #1 shatch Programmer Joined Jul 9, 2004 Messages 346 Location GB Hi I need to write a function which will take in a control and create a new instance of its type (an new instance of it), does anyone have any ideas? Thanks in advance S.
Hi I need to write a function which will take in a control and create a new instance of its type (an new instance of it), does anyone have any ideas? Thanks in advance S.
Jul 20, 2004 #2 chrissie1 Programmer Joined Aug 12, 2002 Messages 4,517 Location BE something like this? I havent tried it! Code: private function f1(byref con1 as object) dim newcontrol as object newcontrol = ctype(con1,con1.gettype) end function Christiaan Baes Belgium If you want to get an answer read this FAQ faq796-2540 What a wonderfull world - Louis armstrong Upvote 0 Downvote
something like this? I havent tried it! Code: private function f1(byref con1 as object) dim newcontrol as object newcontrol = ctype(con1,con1.gettype) end function Christiaan Baes Belgium If you want to get an answer read this FAQ faq796-2540 What a wonderfull world - Louis armstrong
Jul 20, 2004 Thread starter #3 shatch Programmer Joined Jul 9, 2004 Messages 346 Location GB No, tried that, error is con1.gettype is not defined... This is really doing my head in, it seems so simple Upvote 0 Downvote
No, tried that, error is con1.gettype is not defined... This is really doing my head in, it seems so simple
Jul 20, 2004 Thread starter #4 shatch Programmer Joined Jul 9, 2004 Messages 346 Location GB Well, for those of you that are interested and want to use it i found the answer: Dim myType As Type = ControlToReset.GetType Dim objControl As Object = myType.GetConstructor(myType.EmptyTypes).Invoke(Nothing) Glad to have made it in the end Upvote 0 Downvote
Well, for those of you that are interested and want to use it i found the answer: Dim myType As Type = ControlToReset.GetType Dim objControl As Object = myType.GetConstructor(myType.EmptyTypes).Invoke(Nothing) Glad to have made it in the end