473,662 Members | 2,375 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 "interprete d" 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 2605
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.Reflecti on 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**@smartybir d.com> wrote in message
news:O4******** *****@tk2msftng p13.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 "interprete d" 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.reflecti ons as you mention.

Thanks for your help!

Fred
"Rob Teixeira [MVP]" <RobTeixeira@@m sn.com> wrote in message
news:%2******** *******@TK2MSFT NGP10.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.Reflecti on 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**@smartybir d.com> wrote in message
news:O4******** *****@tk2msftng p13.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 "interprete d" 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
2833
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 container page to include the appropriate content from another file in my web space. Static includes are cake:
7
4288
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 SQL thing is all on one line in the actual code.
4
2515
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" button is clicked. In addition, the session variable is reset to zero when the "Empty" button is pressed. The problem is if the value is non-zero and the page is reloaded the value is incremented. It appears as if the "Add" onClick event...
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 and get its value For example: dim vara as string = "1234" dim varb as string = '5678"
3
1505
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 on some conditions of temp1 session. Then display the value on the label. Code like this: <script language="vb" runat=server> Dim var1 as string = "aaa" .........
53
26363
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 variable? My answer: static variable in function and global variable are allocated in head, and automatic variable is allocated in stack. Right?
19
2298
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 is a strange place" - dmr 29 July 1999
9
2326
by: sulekhasweety | last post by:
dear all, can anyone explain the differences between pointer variable and reference variables ?
0
3467
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 do not inherit this value. From "man bash": Shell Variables The following variables are set by the shell:
0
8432
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8343
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8856
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8762
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8545
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
5653
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4347
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2762
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1992
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.