lundi 17 juillet 2017

Changing the value of textbox based on checkboxes and another textbox

I have a textbox that shows the decimal value when certain checkboxes are checked and adding those specific values with the value in a textbox.

for example :

If 2 checkboxes are checked then the value is 16+8 =24 and the value in the textbox is 2. The code I have used applies to every checkbox given below

If CheckBox3.Checked <> 0 Then
        ALMvalue = 16 + Convert.ToInt32(TextBox30.Text) + ALMvalue
        TextBox3.Text = ALMvalue.ToString("X4")

    Else
        ALMvalue = ALMvalue - 16 - Convert.ToInt32(TextBox30.Text)
        TextBox3.Text = ALMvalue.ToString("X4")
    End If

The issue here is that, the text box value keeps aggregating and shows the wrong value. So, if both checkboxes are clicked and the value in the textbox is 2. then it produces the output 8+16+4 (instead of 8+16+2). Is there any way to see if the value in the textbox is unchanged or changed before adding the values.

Let me know if I can improve the question in any way .I am new to vb

Aucun commentaire:

Enregistrer un commentaire