using flag to differentiate between two if statements using vb.net

  Kiến thức lập trình

Hi i am trying to write two values on my cal_key register 2705 and 2706 but unfortunately i am able to write just one value.

I want the first if statement to execute and update the reserved cal key value to be 2705 and then when the second if loop executes I want the 2705 value to update to 2706

I am able to do it using button click subroutine so whenever the button is clicked itll update the value but now i am changing the program to when the value reserved cal key is 2705 i want the input label to become false and grey out and when second if statement executes i want the value to update to 2706 and the output label becomes false

 If (Label2705.Enabled = True And Form1.INPUT_VOLTAGE > 9800) Then

     Label2705.Enabled = False
     Label2706.Enabled = True
     Dim recombinedValue As UShort
     Dim result As String = String.Empty


     recombinedValue = CUShort((CUShort(Form1.highbyte) << 8) Or CUShort(Form1.lowbyte))

     result = ("recombinedValue:" & recombinedValue.ToString("X2"))
     Form1.RESERVED_CAL_KEY = recombinedValue

     Form1.cmd = 2

 End If



 If (Label2705.Enabled = False) Then
     Dim result1 As String = String.Empty
     Dim recombined1Value As UShort
     Label2706.Enabled = False


     recombined1Value = CUShort((CUShort(Form1.highbyte1) << 8) Or CUShort(Form1.lowbyte1))

     result1 = ("recombinedValue:" & recombined1Value.ToString("X2"))
     Form1.RESERVED_CAL_KEY = recombined1Value

     Label2706.Enabled = False

     Form1.cmd = 5
 End If

i tried adding flags as well but that didnt help or maybe it wasnt the right way

Theme wordpress giá rẻ Theme wordpress giá rẻ Thiết kế website

LEAVE A COMMENT