473,386 Members | 1,796 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.

Name of Variable at Runtime

Hi

Is there any way of finding out the name of a variable at Runtime?

I am working on solution to add all member variables of a class to a
collection and write them to file in pairs of name=value, that will save the
need to modify the file read/write method each time I add a member variable
to the class as well as ther initial code

The only other way is to use class object or add an extra member to the
collection for each memeber in the correct order

Thank you,
Shmuel Shulman
Nov 21 '05 #1
2 3419
"S Shulman" <sm*******@hotmail.com> schrieb:
Is there any way of finding out the name of a variable at Runtime?

I am working on solution to add all member variables of a class to a
collection and write them to file in pairs of name=value, that will save
the need to modify the file read/write method each time I add a member
variable to the class as well as ther initial code


\\\
Imports System.Reflection
Imports System.Reflection.BindingFlags
Imports System.Reflection.MemberTypes
..
..
..
Dim typ As Type = GetType(Form1)
For Each fi As FieldInfo In typ.GetFields(Instance Or NonPublic)
Dim Value As Object = fi.GetValue(Me)
Dim s As String
Try
s = Value.ToString()
Catch ex As Exception
s = ""
End Try
MsgBox(fi.Name & " = " & s)
Next fi
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #2
"S Shulman" <sm*******@hotmail.com> schrieb
Hi

Is there any way of finding out the name of a variable at Runtime?

I am working on solution to add all member variables of a class to a
collection and write them to file in pairs of name=value, that will
save the need to modify the file read/write method each time I add a
member
variable to the class as well as ther initial code

The only other way is to use class object or add an extra member to
the collection for each memeber in the correct order


http://msdn.microsoft.com/library/en...asp?frame=true

http://msdn.microsoft.com/library/en...asp?frame=true

Armin

Nov 21 '05 #3

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

Similar topics

3
by: Matt | last post by:
<% hour = Request("controlname") %> will yield the following error: Microsoft VBScript runtime (0x800A01F5) Illegal assignment: 'hour' However, if I declare hour, then it is fine. <% Dim...
22
by: nobody | last post by:
hello everybody, is there a way of creating an array with help of a function that would accept the name of this array as a parameter and then create global Array type variable of that name? so...
4
by: Byron | last post by:
I am trying to come up with generic routines that can create a reference to a variable on the fly. Assume every form has a variable named for the form, followed by 'foo'. For instance, a form...
10
by: cpp | last post by:
I am trying to find out how to assign the name of a variable (aka identifier) given a string for this name. For example: string s = "whatever"; How can I obtain the following expression:...
4
by: Lucas Sain | last post by:
Hi, I think thta for this I have to use reflection... but I'm not shure. How can I find/get an object at runtime by looking for its name that is stored in a variable. For example: I have a...
5
by: SunnyDrake | last post by:
HI! I wrting some program part of it is XML config parser which contains some commands(for flexibility of engenie). how do i more simple(if it possible not via System.Reflection or...
21
by: Jon Slaughter | last post by:
Is it possible to get the name of an instance of an object? I want to display it for debugging purposes but don't have a clue about how to go about it. i.e., I want something like(psuedo) ...
7
by: RSH | last post by:
This is probably a very simple question but... How do I get the instantiated name of an object from within the class? Example: Sub main Dim c1 as new TestClass() c1.PrintName()
6
by: William | last post by:
for example, I have a global object: extern Object myobj; Can gcc get this object by using string "myobj" at runtime?? I know C++ rtti doesnt support this, but I dont know if gcc can , ...
2
by: Joey | last post by:
I am querying a DataSet with LINQ. I am running into a problem when trying to construct my query because in the "from" clause I do not know the table name (range variable) until runtime. Possible...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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,...

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.