473,508 Members | 2,384 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

variable interpreting in VB.NET

I'm new to VB.NET and I have a situation in which I would like to interpret
a varialble - this may have another name in vb so I will explain what I
mean.

In FoxPro you can "interpret" a variable and get its value

For example:

dim vara as string = "1234"
dim varb as string = '5678"

dim myvar as string
dim myresult as string

myvar = "vara"
myresult = &myvar

In the last line myvar is "interpreted" using the "&" to be "vara" and the
variable "myresult" obtains the value that is in "vara" just as if I had the
following statement:

myresult = vara

Does anyone know if there is a way to do this in VB.NET - or for that matter
what this is called?

Your help would be greatly appreciated!

Thanks,

Fred
Nov 20 '05 #1
2 2584
Basically, the value of myvar is a string representing the name of another
value.
Fox storage is a little different from other languages in some respects, and
I'm not sure there is *a* name for this sort of thing in VB, but it's
basically a use of RTTI (run-time type information) and
Reflection/Inspection.
In VB, you can use the CallByName function to do something similar. However,
CallByName is just a short-cut to the much richer functionality found in the
System.Reflection namespace, which allows you to inspect and call any method
defined in a class/structure, as well as access any class members by name.
In comparison, CallByName is rather limited.

-Rob Teixeira [MVP]

"Fred Nelson" <fr**@smartybird.com> wrote in message
news:O4*************@tk2msftngp13.phx.gbl...
I'm new to VB.NET and I have a situation in which I would like to interpret a varialble - this may have another name in vb so I will explain what I
mean.

In FoxPro you can "interpret" a variable and get its value

For example:

dim vara as string = "1234"
dim varb as string = '5678"

dim myvar as string
dim myresult as string

myvar = "vara"
myresult = &myvar

In the last line myvar is "interpreted" using the "&" to be "vara" and the
variable "myresult" obtains the value that is in "vara" just as if I had the following statement:

myresult = vara

Does anyone know if there is a way to do this in VB.NET - or for that matter what this is called?

Your help would be greatly appreciated!

Thanks,

Fred

Nov 20 '05 #2
Rob:

Thanks for the post - I have checked out CallByName and it appears to do
everything that I need for this application so far.

I will also take a look at the system.reflections as you mention.

Thanks for your help!

Fred
"Rob Teixeira [MVP]" <RobTeixeira@@msn.com> wrote in message
news:%2***************@TK2MSFTNGP10.phx.gbl...
Basically, the value of myvar is a string representing the name of another
value.
Fox storage is a little different from other languages in some respects, and I'm not sure there is *a* name for this sort of thing in VB, but it's
basically a use of RTTI (run-time type information) and
Reflection/Inspection.
In VB, you can use the CallByName function to do something similar. However, CallByName is just a short-cut to the much richer functionality found in the System.Reflection namespace, which allows you to inspect and call any method defined in a class/structure, as well as access any class members by name.
In comparison, CallByName is rather limited.

-Rob Teixeira [MVP]

"Fred Nelson" <fr**@smartybird.com> wrote in message
news:O4*************@tk2msftngp13.phx.gbl...
I'm new to VB.NET and I have a situation in which I would like to

interpret
a varialble - this may have another name in vb so I will explain what I
mean.

In FoxPro you can "interpret" a variable and get its value

For example:

dim vara as string = "1234"
dim varb as string = '5678"

dim myvar as string
dim myresult as string

myvar = "vara"
myresult = &myvar

In the last line myvar is "interpreted" using the "&" to be "vara" and the variable "myresult" obtains the value that is in "vara" just as if I had

the
following statement:

myresult = vara

Does anyone know if there is a way to do this in VB.NET - or for that

matter
what this is called?

Your help would be greatly appreciated!

Thanks,

Fred


Nov 20 '05 #3

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

Similar topics

3
2818
by: rd | last post by:
I wanted to do this: <!-- #include virtual = <%=request("page")%> --> But, that's doesn't work. Help?! I have a static "container" asp page. Based on a querystring variable, I want the...
7
4269
by: Richard Hollenbeck | last post by:
Help! I don't know why this isn't working: Private Sub Combo9_Change() Dim UsersCourseSelection As String UsersCourseSelection = Me("Combo9").Value Combo13.Visible = True 'the following...
4
2504
by: N. Demos | last post by:
Hello, I'm learning ASP.NET, and am having a strange problem with some example code from the book I'm using. The code increments and displays the value stored in a session variable when the "Add"...
0
308
by: Fred Nelson | last post by:
I'm new to VB.NET and I have a situation in which I would like to interpret a varialble - this may have another name in vb so I will explain what I mean. In FoxPro you can "interpret" a variable...
3
1500
by: vincenthkh | last post by:
I am new in ASP.net programming (but have ASP skill) and have some problems. I have a ASPX page. First I declare the variable, then I want to include the different values to the variable based...
53
26330
by: fdmfdmfdm | last post by:
This is an interview question and I gave out my answer here, could you please check for me? Q. What are the memory allocation for static variable in a function, an automatic variable and global...
19
2281
by: Hapa | last post by:
Does only reading (never writing) of a variable need thread synchronisation? Thanks for help? PS. Anybody knows a Visual C++ news group?
7
252
by: Richard Heathfield | last post by:
Chris Dollin said: Because it isn't there. -- Richard Heathfield <http://www.cpax.org.uk> Email: -http://www. +rjh@ Google users: <http://www.cpax.org.uk/prg/writings/googly.php> "Usenet...
9
2313
by: sulekhasweety | last post by:
dear all, can anyone explain the differences between pointer variable and reference variables ?
0
3439
by: Cameron Simpson | last post by:
On 17Aug2008 21:25, John Nagle <nagle@animats.comwrote: Because $HOSTNAME is a bash specific variable, set by bash but NOT EXPORTED! Like $0 and a bunch of other "private" variables, subprocesses...
0
7223
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
7489
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5624
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5047
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4705
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3191
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3179
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
762
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
414
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.