Click here to Skip to main content
13,189,811 members (64,991 online)
Rate this:
Please Sign up or sign in to vote.
See more:
private void textBox10_Click(object sender, EventArgs e)
            int a = 0, b = 0, c = 0;
            if (!int.TryParse(textBox8.Text,
                                out a))
                MessageBox.Show("u need to enter value");
            else if (!int.TryParse(textBox9.Text,
                                    out b) || (b > a))
                MessageBox.Show("u entered greater value");
                c = a - b;
                textBox10.Text = c.ToString(

while inserting data..this code performing subtraction correctly, then i just retrieved "added" data from DB using search query.. now textbox8,9,10 will have fetched data from DB like 12,8,4... now if i change the value of textbox9 and textbox8 and click textbox10 it need to perform subtraction(click event for textbox10) but its not performing simply MessageBox in first if statement displaying...
why this happening
Posted 17-Jan-13 6:45am
Updated 18-Jan-13 3:48am
jibesh 17-Jan-13 18:11pm
did you set the textBox8 with proper DB value?
selva_1990 18-Jan-13 9:40am
sorry for late response... ya i just retrieve value for all three textbox...
if am adding data in textbox8 as 10, textbox9 as 5 then automatically calculate once i click in textbox10 as 5..... now if i fetch using search all data will be in three textbox... now if i change value in textbox8 and textbox9 and click in textbox10 it showing messagebox as u need to enter value... so now i need to perform calculation after fetching data
selva_1990 18-Jan-13 12:05pm
i got answer :)
CHill60 18-Jan-13 10:32am
What are you actually typing into textbox8 ?
selva_1990 18-Jan-13 11:55am
again number only i'll give to calculate

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

That's not really somethign we can fix for you from here - you need to look more closely at why it's failing the first TryParse operation.

Put a breakpoint on the if statement, and look at exactly what is in the textBox8.Text with the debugger - there may be a tab or other character which is difficult to see.

It might also be worth showing the code you use to load the textbox if you can't see anything obvious with the debugger.
Marcus Kramer 18-Jan-13 11:21am
selva_1990 18-Jan-13 12:04pm
ya i got thanks.. i mentioned database field type as money so if i give value 22 it will take as 22.0000 bcoz of that problem... good hints to find my mistake thanks lot :)
OriginalGriff 18-Jan-13 12:22pm
You're welcome!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web02 | 2.8.171016.2 | Last Updated 18 Jan 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100