Wrox Programmer Forums
|
VB How-To Ask your "How do I do this with VB?" questions in this forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 29th, 2005, 08:15 AM
Authorized User
 
Join Date: Mar 2005
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to akash Send a message via MSN to akash
Default VB TEXT BOX VALUE

I have variable name stored in text1.text as a text. I want to access value of this variable name
For e.g.
Dim aa as double
aa=123456
text1.text = "aa"
'' stored in text1.text as aa not value directly
in my program i want to access
value of text stored in text1.text i.e. aa

PLease help

Thx
Akash



 
Old April 29th, 2005, 08:20 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

hi there...

only way to do that is put the variables in a class, make a property for each class, and use call by name to get the values...

HTH

Gonzalo
 
Old April 29th, 2005, 10:51 AM
Friend of Wrox
 
Join Date: Nov 2004
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

When a program is compiled, all of these strings of characters that we use to identify values that we are storing get changed to sequentially-generated IDs that only the machine can use.

So as your above code gets compiled, enough room for a double is eked out of memory, and given an ID that the compiler uses. Then, each time it comes to “aa” in your code, and while the context establishes that those two letters should be interpreted as a variable name, the code is generated to go get the value from the location that the compiler has set aside for that variable. But the compiler does not call it “aa.”

In the case of short variable names, there is not musch difference either way, but with the fact that variable names can be 255 characters, it makes sense for the compiler to “tokenize” variables as part of the compilation process.

But due to this, there is no “aa” for the program to find.

You can create a Collection, and name the items in it, and retrieve the value of those items through the string that is stored in your textbox.

I think what Gonzalo meant to say was “ . . . put the variables in a class, make a property for each [u]variable in the</u> class, . . .”

But both of these methods requires that you know in advance how many variables you will be using, and what their names will be. (Well, actually you [u]could</u> dynamically load a Collection... A lot of work though.)

Brian





Similar Threads
Thread Thread Starter Forum Replies Last Post
Grab Values From List Box into Text Box phungleon VB How-To 2 June 19th, 2008 10:33 PM
Count in combo box(display results in text box) mboyisis Access 4 April 4th, 2008 07:08 AM
Assigning a value to a report text box using VB Enoch Access 2 January 19th, 2006 01:57 PM
Printing a VB Text Box Directly To a Printer CB78 Beginning VB 6 6 February 16th, 2004 01:54 PM
Creating an Input Mask in a text box in VB.NET ysu_computer_lab VS.NET 2002/2003 1 November 5th, 2003 02:40 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.