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 PostSee this link execute math expression via CodeDom
Much simpler approach: Evaluate expression …
Jump to PostWhoops!
Jump to Postint a,b,c;
a = Convert.ToInt32(textBox1.Substring(1,1);
b = Convert.ToInt32(textBox1.Substring(2,2);
c = a+b;
textbox3.text = convert.toString(c);hope this help...
Jump to Postjust make sure, ur txt1.Text doesnt not have any special characters like '+' that u have mentioned.
for example ur txt1.Text has '1+' or so, u cannot convert it.
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.