I am currently working on a project where I create a custom calculator that saves your own formulas.
There is numeric up-down element which allows the user to set a certain amount of variables in the calculator. Once the variables they are using are listed, they type in the problem and it displays the result in an output textbox.
The way I want this to work is that there will be a variable for each textbox. I want the name of the variable to be dynamically changed to the text in the textbox.
In the problem the user inputs it is set to a string which is solved by the computer.
For example
var unnamedVarForTextbox1;
//pseudo code
unnamedVarForTextbox1.name = textbox1.Text; //let's say var1 is l for length (user input)
unnamedVarForTextbox2.name = textbox2.Text; //let's say var2 is w for width (user input)
unnamedVarForTextbox3.name = textbox3.Text; //let's say var3 is h for height (user input)
string userProblem = problem.Text;
//problem.Text is l*w*h (so volume)
//Displays solved problem in output textbox
output.text = userProblem;
How would I do this? If there is another way to achieve my goal, or if you need any photos please let me know, and thank you in advance.
Here are some mildly related websites: swift / changing name of variable in loop and Is it possible to dynamically name variables based off user input?
Name, though. Not sure if it will help as you can set it freely and thus it is not guaranteed to be unique. - The usual workaround is a Dictionary.