PC Review


Reply
Thread Tools Rate Thread

Creating an Unknown Object

 
 
astroboy
Guest
Posts: n/a
 
      2nd Aug 2004
How do I create an object of unknown type
like this example do in Java
http://www.churchillobjects.com/c/11042b.html


 
Reply With Quote
 
 
 
 
Imran Koradia
Guest
Posts: n/a
 
      2nd Aug 2004
look at the overloaded Activator.CreateInstance method.
you can also use the vb6 CreateObject method
there should be some examples in the MSDN help for these methods..

hope this helps..
Imran.

"astroboy" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> How do I create an object of unknown type
> like this example do in Java
> http://www.churchillobjects.com/c/11042b.html
>
>



 
Reply With Quote
 
Herfried K. Wagner [MVP]
Guest
Posts: n/a
 
      3rd Aug 2004
* "astroboy" <(E-Mail Removed)> scripsit:
> How do I create an object of unknown type
> like this example do in Java
> http://www.churchillobjects.com/c/11042b.html


\\\
Private Function CreateClassByName( _
ByVal PartialAssemblyName As String, _
ByVal QualifiedClassName As String _
) As Object
Return _
Activator.CreateInstance( _
[Assembly].LoadWithPartialName( _
PartialAssemblyName _
).GetType(QualifiedClassName) _
)
End Function
///

Usage:

\\\
Dim c As Control = _
DirectCast( _
CreateClassByName( _
"System.Windows.Forms", _
"System.Windows.Forms.Button" _
), _
Control _
)
With c
.Location = New Point(10, 10)
.Size = New Size(80, 26)
.Text = "Hello World"
End With
Me.Controls.Add(c)
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Creating a derived object from a base object benliu Microsoft C# .NET 10 6th Dec 2006 11:18 AM
Unknown object in a worksheet =?Utf-8?B?TGVl?= Microsoft Excel Misc 3 22nd Nov 2005 08:14 PM
unknown object in cell =?Utf-8?B?c29uamFyZWRtb29u?= Microsoft Excel Misc 5 14th Sep 2005 09:35 PM
Get String from unknown object Webgour Microsoft C# .NET 1 17th Feb 2005 12:07 AM
Unknown Object Chris Laycock Microsoft Excel Charting 1 16th Feb 2005 02:21 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:48 PM.