I am trying to convert a string into integer which contain a mathematical operator e.g "1+1" but I am always getting "Input string was not in a correct format." error during execution.
azfarhus
0
Newbie Poster
Recommended Answers
Jump to PostWhat do you expect (hope) to happen?
Jump to Postint a, b, c;
a = Convert.ToInt32(textBox1.Text);
b = Convert.ToInt32(textBox2.Text);
c = a * b;
textBox3.Text = c.ToString();
It will help u.
Jump to PostWhat you want to do is not easy.
.Net does not automatically process strings like you expect.
You will need to parse the string yourself; identify the numbers and operators and then perform the appropriate function(s) to get the result.
Google "Parse Math String" as there is a good chance …
Jump to PostSee this link execute math expression via CodeDom
Much simpler approach: Evaluate expression …
Jump to PostSee this link execute math expression via CodeDom
Much simpler approach: Evaluate expression and …
All 21 Replies
nick.crane
342
Veteran Poster
azfarhus
0
Newbie Poster
virusisfound
0
Junior Poster
azfarhus
0
Newbie Poster
nick.crane
342
Veteran Poster
powerbox
13
Light Poster
azfarhus
0
Newbie Poster
nick.crane
342
Veteran Poster
azfarhus
0
Newbie Poster
nick.crane
342
Veteran Poster
azfarhus
0
Newbie Poster
nick.crane
342
Veteran Poster
azfarhus
0
Newbie Poster
azfarhus
0
Newbie Poster
nick.crane
342
Veteran Poster
nick.crane
342
Veteran Poster
Medalgod
7
Light Poster
vsa000
1
Newbie Poster
nick.crane
342
Veteran Poster
arunkumars
14
Junior Poster
arunkumars
14
Junior Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.