Private Sub cmd1_Click() If X=False Then cmd1.Caption="Area 1 ON" ClrPortBit &H37A,1 X= True Else cmd1.Caption="Area 1 OFF" SetPortBit &H37A,1 X=False End If End Sub Private Sub cmd2_Click() If Z=False Then cmd2.Caption="Area 2 ON" ClrPortBit &H37A,0 Z= True Else cmd2.Caption="Area 2 OFF" SetPortBit & H37A,0 Z=False End If sensor= lblwater.Caption If sensor =0 Then Label2.Caption="The Power is switched off from Generation site." If X=True Then MSComm1.Output="at" Call delay MSComm1.Output=Chr(13) Call delay MSComm1.Output="at+cmgf=1" Call delay MSComm1.Output=Chr(13) Call delay MSComm1.Output="at+cmgs=" Call delay MSComm1.Output=Chr(34) Call delay MSComm1.Output=txtno1.Text Call delay MSComm1.Output=Chr(34) Call delay MSComm1.Output=Chr(13) Call delay MSComm1.Output=Label2.Caption & DateTime.Now 'gsm message Call delay MSComm1.Output=Chr(26) Call delay MSComm1.Output="at+cmgs=" Call delay MSComm1.Output=Chr(34) Call delay MSComm1.Output=txtno2.Text Call delay MSComm1.Output=Chr(34) Call delay MSComm1.Output=Chr(13) Call delay MSComm1.Output=Label2.Caption & DateTime.Now 'gsm message Call delay MSComm1.Output=Chr(26) Call delay cmdgsm.Caption="GSM OFF" X=False End If ElseIf sensor = 8 Then Label2.Caption = "The Power is switched off between Generation site and Sub Station" If X = True Then MSComm1.Output = "at" Call delay MSComm1.Output = Chr(13) Call delay MSComm1.Output= "at+cmgf=1" Call delay MSComm1.Output = Chr(13) Call delay MSComm1.Output = "at+cmgs=" Call delay MSComm1.Output= Chr(34) Call delay MSComm1.Output= txtno1.Text Call delay MSComm1.Output= Chr(34) Call delay MSComm1.Output = Chr(13) Call delay MSComm1.Output = Label2.Caption & DateTime.Now 'gsm message Call delay MSComm1.Output = Chr(26) Call delay MSComm1.Output="at+cmgs" Call delay MSComm1.Output= Chr(34) Call delay MSComm1.Output= txtno2.Text Call delay MSComm1.Output= Chr(34) Call delay MSComm1.Output = Chr(13) Call delay MSComm1.Output = Label2.Caption & DateTime.Now 'gsm message Call delay MSComm1.Output = Chr(26) Call delay cmdgsm.Caption = "GSM OFF" X=False End If ElseIf sensor = 24 Then Label2.Caption = "The Power is switched off between Substation and areas." If X = True Then MSComm1.Output = "at" Call delay MSComm1.Output=Chr(13) Call delay MSComm1.Output="at+cmgs=1" Call delay MSComm1.Output = Chr(13) Call delay MSComm1.Output="at+cmgs=" Call delay MSComm1.Output = Chr(34) Call delay MSComm1.Output=txtno1.Text Call delay MSComm1.Output = Chr(34) Call delay MSComm1.Output = Chr(13) Call delay MSComm1.Output = Label2.Caption & DateTime.Now 'gsm message Call delay MSComm1.Output = Chr(26) Call delay MSComm1.Output = "at+cmgs=" Call delay MSComm1.Output=Chr(34) Call delay MSComm1.Output = txtno2.Text Call delay MSComm1.Output = Chr(34) Call delay MSComm1.Output = Chr(13) Call delay MSComm1.Output = Lable2.Caption & DateTime.Now 'gsm message Call delay MSComm1.Output = Chr(26) Call delay cmdgsm.Caption = "GSM OFF" X= False End If ElseIf sensor = 56 Then Label2.Caption = "The Power is switched off between Substation and area1" If X = True Then MSComm1.Output = "at" Call delay MSComm1.Output = Chr(13) Call delay MSComm1.Output = "at+cmgf=1" Call delay MSComm1.Output=Chr(13) Call delay MSComm1.Output = "at+cmgs=" Call delay MSComm1.Output = Chr(34) Call delay MSComm1.Output = txtno1.Text Call delay MSComm1.Output = Chr(34) Call delay MSComm1.Output = Chr(13) Call delay MSComm1.Output = Label2.Caption & DateTime.Now 'gsm message Call delay MSComm1.Output = Chr(26) Call delay MSComm1.Output = "at+cmgs=" Call delay MSComm1.Output = Chr(34) Call delay MSComm1.Output = txtno2.Text Call delay MSComm1.Output = Chr(34) Call delay MSComm1.Output = Chr(13) Call delay MSComm1.Output = Label2.Caption & DateTime.Now 'gsm message Call delay MSComm1.Output = Chr(26) Call delay cmdgsm.Caption = "GSM OFF" X= False End If ElseIf sensor = 88 Then Label2.Caption = "The Power is switched off between Substation and area2" If X= True Then MSComm1.Output = "at" Call delay MSComm1.Output = Chr(13) Call delay MSComm1.Output = "at+cmgf=1" Call delay MSComm1.Output = Chr(13) Call delay MSComm1.Output = "at+cmgs=" Call delay MSComm1.Output = Chr(34) Call delay MSComm1.Output = txtno1.Text Call delay MSComm1.Output = Chr(34) Call delay MSComm1.Output = Chr(13) Call delay MSComm1.Output = Label2.Caption & DateTime.Now 'gsm message Call delay MSComm1.Output = Chr(26) Call delay MSComm1.Output = "at+cmgs=" Call delay MSComm1.Output = Chr(34) Call delay MSComm1.Output = txtno2.Text Call delay MSComm1.Output = Chr(34) Call delay MSComm1.Output = Chr(13) Call delay MSComm1.Output = Label2.Caption & DateTime.Now 'gsm message Call delay MSComm1.Output = Chr(26) Call delay cmdgsm.Caption = "GSM OFF" X= False End IF Else Label2.Caption = "The power is there in the entire distribution grid" End IF If Y = True Then Label5.Caption = Time$ Label6.Caption = Date$ If Check1.Value = 1 Then device1 = True Else device1 = False End If If Check2.Value = Then device2 = False End If If device1=False Then ClrPortBit &H37A, 1 ElseIf (Time$ > Text1.Text And Time$<text2.text and="" device1="True)" mode="hold" />SetPortBit &H37A, 1 Else ClrPortBit &H37A, 1 End If If device2 = False Then ClrPortBit &H37A, 2 ElseIf (Time$ > Text3.Text An Time$<text4.text and="" device2="True)" mode="hold" />SetPortBit &H37A, 0 Else ClrPortBit &H37A, 0 End If End If
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)