Hello guys.

I'm using a Microsoft Word form template to create objects in a form programatically, so depending on the information read by the program from the template.

So, I've got some fields where I store formula data for the form, in which I specify that the value for that field is obtained by multiplying other fields in the template. So I store in the string something like this:

"Text1.Text * Text2.Text"

So I need to convert these string values into variable calls to actually operate these values.

What would be the best way to do this?

7 Years
Discussion Span
Last Post by Mitja Bonca

If you want to do a Math operations over some data, these data have to be a true numbers. You cannot do math operations over strings (like the text property provides of the textBox).
You can do:

int value1 = int.Parse(textBox1.Text);
int value 2 = int.Parse(textBox2.Text);
//put a result into 3rd textBox:
textBox3.Text = (value1 * value2).Tostring();

Hope this clears on which kind of data you can do math operations, and on which you cannot. You can do on all number types, like int, decimal, floaf, double,...

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.