我该如何运行此代码? [英] How do I run this code?

查看:59
本文介绍了我该如何运行此代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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





我尝试过:



我已尝试在WINDOWS表单应用程序中运行此代码



What I have tried:

I HAVE TRIED TO RUN THIS CODE IN WINDOWS FORM APPLICATION

推荐答案

Label6.Caption = Date
Label6.Caption = Date


如果 Check1.Value = 1 然后
device1 = True
其他
device1 = 错误
结束 如果
如果 Check2.Value = 那么
device2 = 错误
结束 如果
如果 device1 = False 那么
ClrPortBit& H37A, 1
ElseIf (时间
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 时间
> Text1.Text And Time


这篇关于我该如何运行此代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆