נעול determine a boolean condition on the fly

  • יום רביעי 30 מאי 2012 14:58
     
      קוד כלול

    I have a boolean condition that I want tthe program to recognize changes when they occur. Currently in order for the program to recognize a change I must restart the program.

    I have tried using a public timer but that didn't work.

    Specifically.....

            D1A.Close()
            D1A = File.OpenText("MEASURE UNITS.TXT")
            D1B = CStr(D1A.ReadLine)
            D1A.Close()
            Dim P7 As String = (D1B)
            If P7.ToLower.Contains("english") Then
                ENGLISH = True And METRIC = False And MIXED = False
            ElseIf P7.ToLower.Contains("metric") Then
                METRIC = True And ENGLISH = False And MIXED = False
            ElseIf P7.ToLower.Contains("mixed") Then
                MIXED = True And ENGLISH = False And METRIC = False
            End If

    I am re-writting the text file "MEASURE UNITS.TXT" labeled (D1B). Depending on this boolean equation different options become available in other parts of the program.

    I need the program to re-adjust the boolean equation on the fly.

    Can this be done??

כל התגובות

  • יום רביעי 30 מאי 2012 15:59
     
     תשובה

    How exactly did the timer not work? Could you post your code for that?

    Also, you should really have better names for your variables. And this doesn't seem to be related to the async CTP in any way, so you should've posted this question into another forum.

  • יום רביעי 30 מאי 2012 21:21
     
      קוד כלול

    svick

    First thanks for your response, believe it or not there are reasons for the variable names.

    I will take your advice and try to find a different thread for this question.

    here is my timer

     Public Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
            D1A.Close()
            D1A = File.OpenText("MEASURE UNITS.TXT")
            D1B = CStr(D1A.ReadLine)
            D1A.Close()
            Dim P7 As String = (D1B)
            If P7.ToLower.Contains("english") Then
                ENGLISH = True And METRIC = False And MIXED = False
            ElseIf P7.ToLower.Contains("metric") Then
                METRIC = True And ENGLISH = False And MIXED = False
            ElseIf P7.ToLower.Contains("mixed") Then
                MIXED = True And ENGLISH = False And METRIC = False
            End If
            D2A.Close()
            D2A = File.OpenText("TOTALIZATION UNITS.TXT")
            D2B = CStr(D2A.ReadLine)
            D2A.Close()
            Dim tu As String
            If D2B = "Tons" Then
                tu = "Tons"
            ElseIf D2B = "Pounds" Then
                tu = "lbs"
            ElseIf D2B = "tonnes" Then
                tu = "t"
            ElseIf D2B = "LTons" Then
                tu = "LTons"
            ElseIf D2B = "kg" Then
                tu = "kg"
            End If
            D10A.Close()
            D10A = File.OpenText("LINE 3 UNITS.TXT")
            D10B = CStr(D10A.ReadLine)
            D10A.Close()
            Dim P8 As String = (D10B)
            If P8.ToLower.Contains("speed") Then
                LIN3SPD = True
                LINE3 = True
                LIN3LD = False
            ElseIf P8.ToLower.Contains("load") Then
                LIN3LD = True
                LINE3 = True
                LIN3SPD = False
            ElseIf P8.ToLower.Contains("no display") _
            Or P8.ToLower.Contains("Date/Time") _
            Then
                LIN3LD = False
                LINE3 = False
                LIN3SPD = False
            End If
        End Sub