473,666 Members | 1,977 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 2606
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
2834
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
2327
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
8871
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
8781
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
8551
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
8640
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7386
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6198
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5664
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
4369
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1776
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.