PC Review


Reply
Thread Tools Rate Thread

Changing the name of a variable using code

 
 
pltaylor3@gmail.com
Guest
Posts: n/a
 
      10th Jan 2007
I have an array that is two wide and an undefined length. The first
column is a name of a variable and the second column is the value of
that variable. How can i define all the items as there name = value?
i.e array(1,0) = X array(1,1) = 23 make it so that X = 23. This is
probably really simple and i would appreciate any help.
thanks
Perry

 
Reply With Quote
 
 
 
 
George Nicholson
Guest
Posts: n/a
 
      10th Jan 2007
I don't think you can make X = 23 but you could create a function to which
you would pass your variable name & get the variable value back so that:
GetFromArray(X) = 23.
(The function would have to loop through the entire array looking for X, get
the corresponding value & exiting the loop once found)

This would allow you to access the array elements much like the elements of
a collection, which raises the question (in my mind at least) if you
wouldn't be better off simply putting your variables into a collection in
the first place. It may be a coin toss depending on what you are doing.

HTH


<(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>I have an array that is two wide and an undefined length. The first
> column is a name of a variable and the second column is the value of
> that variable. How can i define all the items as there name = value?
> i.e array(1,0) = X array(1,1) = 23 make it so that X = 23. This is
> probably really simple and i would appreciate any help.
> thanks
> Perry
>



 
Reply With Quote
 
pltaylor3@gmail.com
Guest
Posts: n/a
 
      10th Jan 2007
They are in two single arrays from a database recordset. I'm up for
any suggestions.

George Nicholson wrote:
> I don't think you can make X = 23 but you could create a function to which
> you would pass your variable name & get the variable value back so that:
> GetFromArray(X) = 23.
> (The function would have to loop through the entire array looking for X, get
> the corresponding value & exiting the loop once found)
>
> This would allow you to access the array elements much like the elements of
> a collection, which raises the question (in my mind at least) if you
> wouldn't be better off simply putting your variables into a collection in
> the first place. It may be a coin toss depending on what you are doing.
>
> HTH
>
>
> <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> >I have an array that is two wide and an undefined length. The first
> > column is a name of a variable and the second column is the value of
> > that variable. How can i define all the items as there name = value?
> > i.e array(1,0) = X array(1,1) = 23 make it so that X = 23. This is
> > probably really simple and i would appreciate any help.
> > thanks
> > Perry
> >


 
Reply With Quote
 
NickHK
Guest
Posts: n/a
 
      11th Jan 2007
Perry,
Not sure what you're trying to achieve, but from the subject, you cannot
change the name of a variable, only its value.
It seems that either you do not need a 2D array, or you are trying to use
arrays/variables incorrectly.

Explain what "X=23" is supposed to do/mean ?

NickHK

<(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> I have an array that is two wide and an undefined length. The first
> column is a name of a variable and the second column is the value of
> that variable. How can i define all the items as there name = value?
> i.e array(1,0) = X array(1,1) = 23 make it so that X = 23. This is
> probably really simple and i would appreciate any help.
> thanks
> Perry
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to get one variable to equal the value of a changing variable (its hard to explain in the subject) Bob Microsoft Access 2 4th Nov 2007 06:50 AM
How to assign the value of the java script variable to a server side variable in C# code behind code? ravindravarman@gmail.com Microsoft Dot NET 1 5th Apr 2007 04:04 PM
How to assign the value of the java script variable to a server side variable in C# code behind code? ravindravarman@gmail.com Microsoft Dot NET 0 5th Apr 2007 07:58 AM
Is there any tool may provide the functionity changing variable's name automaticlly through entire code. zlf Microsoft C# .NET 4 4th Apr 2005 02:40 PM
Changing a code Variable from a form =?Utf-8?B?TmV2aWUgYW5kIFBoaWw=?= Microsoft Access Form Coding 5 17th Feb 2005 01:33 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:59 AM.