how to substract value if criteria mets?
-
Sunday, June 24, 2012 11:33 AM
hello to all,
can any one help me for this
i have a five text boxes in visual basic 2010 form
code to fill textbox1:
Private Sub txtcatgen_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtcatgen.TextChanged If txtcatgen.Text = "GENERALMALE" Then txtba1fees.Text = "510" End If If txtcatgen.Text = "GENERALFEMALE" Then txtba1fees.Text = "495" End If If txtcatgen.Text = "OBCMALE" Then txtba1fees.Text = "510" End If If txtcatgen.Text = "OBCFEMALE" Then txtba1fees.Text = "495" End If If txtcatgen.Text = "SCMALE" Then txtba1fees.Text = "0" End If If txtcatgen.Text = "SCFEMALE" Then txtba1fees.Text = "0" End If If txtcatgen.Text = "STMALE" Then txtba1fees.Text = "0" End If If txtcatgen.Text = "STFEMALE" Then txtba1fees.Text = "0" End If End Subin the textbox2 change the code are:
Private Sub txtba1fees_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtba1fees.TextChanged If txtcatgen.Text = "GENERALMALE" Then txtba1fees1.Text = txtba1fees.Text - "495" ElseIf txtcatgen.Text = "GENERALFEMALE" Then txtba1fees1.Text = txtba1fees.Text - "495" ElseIf txtcatgen.Text = "OBCMALE" Then txtba1fees1.Text = txtba1fees.Text - "495" ElseIf txtcatgen.Text = "OBCFEMALE" Then txtba1fees1.Text = txtba1fees.Text - "495"[Conversion from string "" to type 'Double' is not valid.] ElseIf txtcatgen.Text = "SCMALE" Then txtba1fees1.Text = "0" ElseIf txtcatgen.Text = "SCFEMALE" Then txtba1fees1.Text = "0" ElseIf txtcatgen.Text = "STMALE" Then txtba1fees1.Text = "0" ElseIf txtcatgen.Text = "STFEMALE" Then txtba1fees1.Text = "0" End If End Subin the textbox3 change the code are:
Private Sub txtba1fees1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtba1fees1.TextChanged If txtcatgen.Text = "GENERALMALE" Then txtba1fees2.Text = txtba1fees.Text - txtba1fees1.Text - "485" End If If txtcatgen.Text = "GENERALFEMALE" Then txtba1fees2.Text = txtba1fees.Text - "485" End If If txtcatgen.Text = "OBCMALE" Then txtba1fees2.Text = txtba1fees.Text - txtba1fees1.Text - "485" End If If txtcatgen.Text = "OBCFEMALE" Then txtba1fees2.Text = txtba1fees.Text - "485" End If If txtcatgen.Text = "SCMALE" Then txtba1fees2.Text = "0" End If If txtcatgen.Text = "SCFEMALE" Then txtba1fees2.Text = "0" End If If txtcatgen.Text = "STMALE" Then txtba1fees2.Text = "0" End If If txtcatgen.Text = "STFEMALE" Then txtba1fees2.Text = "0" End If End Sub
in this code the error showing in mention line
please help me it urgent
if is there any other way for achieve this task.
kindly help me.("_")
All Replies
-
Monday, June 25, 2012 9:15 AMModerator
Hi Sunny,
Welcome to the MSDN forum.
I've tested your codes and got this exception if value of txtba1fees is nothing. For your issue, I suggest you validate its value before the calculate.
You can add the following codes in txtba1fees_TextChanged method:
Dim result As Double
If Double.TryParse(txtba1fees.Text, result) = False Then
txtba1fees.Text = 0
End IfI hope this will be helpful.
Best regards,
Shanks Zen
MSDN Community Support | Feedback to us
- Marked As Answer by sanny007 Monday, June 25, 2012 5:06 PM
-
Monday, June 25, 2012 5:08 PM
hello Zen,
thanks for solving my problem.
u are great.
thanks again
if u have time please solve this problem because i am trying this from last one week.
how to generate unique ID based on combobox selection?
thanks again
- Edited by sanny007 Monday, June 25, 2012 5:57 PM

