473,386 Members | 1,827 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

make a classname a variable

Since there is no eval function in VB, is there a way to make a classname a variable? For example;

Dim MyClassInstance1 As New MyClass

Dim somestring as System.String = "MyClassInstance1"
"somestring".someproperty = "somevalue"
....which would set MyClassInstance1.someproperty to "somevalue"
Nov 20 '05 #1
3 886
MyClassInstance1.GetType().Name

Or if you want to make a property:

Public ReadOnly Property ClassName() As String
Get
ClassName = Me.GetType().Name
End Get
End Property
"Stephen Travis" <st*****@iname.com> wrote in message
news:uw**************@TK2MSFTNGP11.phx.gbl...
Since there is no eval function in VB, is there a way to make a classname a variable? For example;
Dim MyClassInstance1 As New MyClass

Dim somestring as System.String = "MyClassInstance1"
"somestring".someproperty = "somevalue"
...which would set MyClassInstance1.someproperty to "somevalue"

Nov 20 '05 #2
Hi Stephen,
Since there is no eval function in VB, is there a way to make a
classname a variable? For example;

Dim MyClassInstance1 As New MyClass

Dim somestring as System.String = "MyClassInstance1"
"somestring".someproperty = "somevalue"


Doesn't work that way. You should use Reflection instead, look at the
classes in the System.Reflection Namespace. It's a bit too complex to be
explained here ...

Regards,

Frank Eller
www.frankeller.de
Nov 20 '05 #3
* "Stephen Travis" <st*****@iname.com> scripsit:
Since there is no eval function in VB, is there a way to make a classname a variable? For example;

Dim MyClassInstance1 As New MyClass

Dim somestring as System.String = "MyClassInstance1"
"somestring".someproperty = "somevalue"


See:

<URL:http://groups.google.de/groups?selm=c78n0i%2411kno%241%40ID-208219.news.uni-berlin.de>

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Joshua Beall | last post by:
Hi All, I have been trying to dynamically call a static member function, as follows: $className = 'MyClass'; $methodName = 'MyMethod' $result = $className::$methodName(); However, I get a...
3
by: Sam | last post by:
I wrote a script to show or hide items in an HTML list (<ul id="stuff">) depending on whether a list-item's CLASS attribute matches an input string (catString), which is chosen from a SELECT menu....
5
by: http://www.douglassdavis.com | last post by:
Why is it that I can do this: $obj= new $classname(); But not this: $classname::astaticfunc() I would like to call a static function when I only have the class name in a variable and the...
1
by: Tee | last post by:
Hi, my question is as the topic, can we make a long statement become short by pre-declare it. sorry if you can't understand what I asked, as I am not too sure how to ask it, but below is the...
10
by: darrel | last post by:
I have this structure: mypage.aspx (class = mypage) myusercontro.ascx On the mypage.aspx I can declare a variable: animal = "monkey" I can read this from the UC by simply doing this:...
6
by: Selden McCabe | last post by:
I have a form with a bunch of image buttons. When the user moves the mouse over a button, I want to do two things: 1. change the Imagebutton's picture, and 2. make another control visible. I'm...
5
by: Grant Merwitz | last post by:
I have a basic object in an array. I bind this class to a gridview. How can i make this class sortable? Here's an example class public class MyClass { public MyClass(classname, classtype)
7
by: buntyindia | last post by:
I have the following scrollable table I have to implemet a functionality that I can select a row in it & display that data in popup window.. Any hints/example or similar available implementation?...
18
by: Gabriel Rossetti | last post by:
Hello everyone, I had read somewhere that it is preferred to use self.__class__.attribute over ClassName.attribute to access class (aka static) attributes. I had done this and it seamed to work,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.