Click here to Skip to main content
15,895,084 members
Please Sign up or sign in to vote.
2.00/5 (2 votes)
See more:
i want to store manually entered textbox value.
i have three text boxes for using calculation
and one button will give actual calculation value and it will store in one variable.

txtbox1 = 10
txtbox2 = 20
txtresult = 30(assuming value) this text box also i am entering manually.

when i click button it will give you actual result of txtbox1 + txtbox2. and this value will compare with which i have entered txtresult textbox value.

then it will show is that result is correct or not on a lable.


please help me.....
Posted

1 solution

We do not do your homework: it is set for a reason. It is there so that you think about what you have been told, and try to understand it. It is also there so that your tutor can identify areas where you are weak, and focus more attention on remedial action.

Try it yourself, you may find it is not as difficult as you think!

But this is a trivial problem.
First, find each text boxes value: use the Text property[^].
Then convert each value to an integer: use int.TryParse[^]
Then add the values, and use if to compare them.
You can then post the result message to the label Text property.
 
Share this answer
 
Comments
devchina 7-Mar-15 0:24am    
If rdbAdd.Checked Then
input3 = Integer.Parse(txtResult.Text) 'Assumed value Manullay entered
txtResult.Text = Val(txtInput1.Text) + Val(txtInput2.Text)
compare = txtResult.Text 'Actual result value
End If
then i have compared these two results in this way

x = 1
If input3 = compare Or input3 <> compare Then
txtCorrect.Text = x 'compared results i want to show in correct and incorrect text boxes same time
txtIncorrect.Text = x //wrong result
End If

please help me.....
OriginalGriff 7-Mar-15 5:33am    
First, I said to use TryParse, not Parse: you cannot assume your user will enter only valid data - TryParse lets you check, and give him a specific error when he makes a mistake. Parse just gives an exception and your app crashes.

Second, what did you expect this to do?

If input3 = compare Or input3 <> compare Then

"A equals B or A doesn't equal B" doesn't care what values are in A or B - it will always be true:
A B Result
0 0 true - because 0 is equal to 0
1 0 true - because 1 is not equal to 0
1 1 true - because 1 is equal to 1
0 1 true - because 0 is not equal to 1

So regardless of the values your user enters, you will always execute the same code!

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900