do any one know any command that take the number in the textbox to a calculation by itself? eg. imagine textbox below I type 1234+4214312 | 1234+4214312 | is there any command that will calculate it? like this is the eg. variableA =(command for calcualtion) int32.parse(textbox.text); actually I am trying to do a short cut method if possible for a simple pluse minus div and time and also with brackets ( ) that mean do the sum (B+C) first in A(B+C) calculator. The calculation operation have to be observed. so I type out the oparation in the textbox nicely like textbox 1 + 2 / 3 *(2+5)/200 - 5 and the equal button will be coding with, calculate textbox = A; textbox.Text += string.Format("add equal sign" A); there is some error up here I don know how to do. cannot find ways. this is the way I add in the button command same goes to the number button Code: private void button12_Click(object sender, EventArgs e) { textBox1.Text += " - "; } private void button13_Click(object sender, EventArgs e) { textBox1.Text += " * "; } private void button14_Click(object sender, EventArgs e) { textBox1.Text += " / "; } private void button16_Click(object sender, EventArgs e) { textBox1.Text += " *( "; } private void button17_Click(object sender, EventArgs e) { textBox1.Text += " ) "; } anyone can help me some. Sorry for the my bad english.
I dont think there can exist any such functionality. Either you need to write it yourself or find on net something that is exactly what you are looking for.
does anyone know how to use a try and catch function ? I need examples plz any C# program that has simple explain for it. Maybe I will use try and catch for calculation but I need to understand this function before I can do it.
Code: try { int res = 0; for (int i = 2; i >= 0; i--) res = 10 / i; // <-- Will get an exception of Divide by Zero when i = 0 } catch (Exception) { System.Console.WriteLine("Caught an exception"); // Will catch the exception }
Thanks for it but I still need more example because I don know how it really work. I got anyother question which is I need to know a command that is: if I press "(" and ")" in the textbox it will start calculate the total for sum in the brackets B+C first like eg. A (B+C) before it will multiply the A. I need command and sample for using it. There is any small problem with the textbox sometime got problem with the int and string stuff so I don like textbox something, but labels can slove it. maybe you got better ideal sloving it.
Instead of that you need to be using Prefix or postfix notation. Try http://www.cs.man.ac.uk/~pjj/cs2121/fix.html as that will help you in converting any mathematical expression and evaluate that using the BODMAS Rule
I need help !!! does anyone know how to declare variable as accept 2 thing or more like number and sign like *,/ ,+, - and store it.
hello try and catch blocks are use for handle exception art run time error are two types compile time errors nad run time errors when you have errors at compile time means spell mistake or any wrong statement and while you are not sort out that errors you are not able to run your programme. But run time error isthat when you use such command which you are not difine for example you difine a data in string formate and trying to calculate addition with another string or another dararype rhar is not possible and your programme will behave uncoditionaly and it teminate.but when you use try and carch block it prevent for uncoditionaly temination of programme and flash a message to user for the approriate reasone .if you want to know any other question you are mostwlcome
try { some code } catch(Exception ex){System.Console.WriteLine("Exception" + ex.Message + " StackTrace: " + ex.Stacktrace);}