Click here to Skip to main content
15,895,740 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
http://i58.tinypic.com/25fndc6.jpg[^]
how can i put the negative number to change textbox?like the picture below


here my code!!
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
       Dim i As Double = txtpayment.Text
       i -= txtname.Text
       txtbalance.Text = +-i.ToString


   End Sub
Posted
Updated 3-Mar-14 1:22am
v5

1 solution

Well, I would suggest starting by not trying to subtract a name from a number - it generally doesn't work too well...

I would also suggest using int.TryParse to convert the textbox values to numbers - with error reporting if the user types a non-numeric value.
VB
Dim charge As Integer
If Not Integer.TryParse(txtCharge.Text, charge) Then
    ' Report error
    ...
    Return
End If
Dim payment As Integer
If Not Integer.TryParse(txtPayment.Text, payment) Then
    ' Report error
    ...
    Return
End If
Dim balance As Integer = charge - payment
txtBalance.Text = balance.ToString()
 
Share this answer
 
Comments
Member 10617989 3-Mar-14 11:36am    
sorry dude but your answer is not exactly my what i want to do..in this case i want to compute the charge and payment so charge - payment = balance .... so this is the problem when the answer is become negative i think this not a balance...it is a change ..so i trying to say if the answer is become negative the answer fill to another textbox which is the change ....
OriginalGriff 3-Mar-14 11:42am    
Ah! You need to explain these things... :laugh:
Do exactly as above, but replace the last line with:
If balance >= 0 Then
txtBalance.Text = balance.ToString()
Else
txtChange.Text = balance.ToString()
End If
Member 10617989 3-Mar-14 19:16pm    
show me the whole code so i can understand what your saying

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