📄 继电器控制.frm
字号:
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 4080
TabIndex = 6
Top = 720
Width = 855
End
Begin VB.CommandButton Command4
Caption = "四开"
BeginProperty Font
Name = "楷体_GB2312"
Size = 15
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 2400
TabIndex = 5
Top = 2520
Width = 855
End
Begin VB.CommandButton Command3
Caption = "三开"
BeginProperty Font
Name = "楷体_GB2312"
Size = 15
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 2400
TabIndex = 4
Top = 1920
Width = 855
End
Begin VB.CommandButton Command2
Caption = "二开"
BeginProperty Font
Name = "楷体_GB2312"
Size = 15
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 2400
TabIndex = 3
Top = 1320
Width = 855
End
Begin VB.CommandButton Command1
Caption = "一开"
BeginProperty Font
Name = "楷体_GB2312"
Size = 15
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 2400
TabIndex = 2
Top = 720
Width = 855
End
Begin VB.Label Label3
Caption = "波特率"
BeginProperty Font
Name = "楷体_GB2312"
Size = 18
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 615
Left = 360
TabIndex = 21
Top = 1440
Width = 1815
End
Begin VB.Label Label2
Caption = "串口"
BeginProperty Font
Name = "楷体_GB2312"
Size = 18
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 615
Left = 360
TabIndex = 20
Top = 480
Width = 1215
End
Begin VB.Label Label1
Alignment = 2 'Center
Caption = "继电器控制程序"
BeginProperty Font
Name = "楷体_GB2312"
Size = 21.75
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 1440
TabIndex = 1
Top = 240
Width = 3615
End
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim guan, kai As String
Private Sub Combo1_Click()
If Combo1.Text = "COM1" Then
MSComm1.PortOpen = False
MSComm1.CommPort = 1
MSComm1.PortOpen = True
ElseIf Combo1.Text = "COM2" Then
MSComm1.PortOpen = False
MSComm1.CommPort = 2
MSComm1.PortOpen = True
ElseIf Combo1.Text = "COM3" Then
MSComm1.PortOpen = False
MSComm1.CommPort = 3
MSComm1.PortOpen = True
ElseIf Combo1.Text = "COM4" Then
MSComm1.PortOpen = False
MSComm1.CommPort = 4
MSComm1.PortOpen = True
ElseIf Combo1.Text = "COM5" Then
MSComm1.PortOpen = False
MSComm1.CommPort = 5
MSComm1.PortOpen = True
Else:
MSComm1.PortOpen = False
MSComm1.CommPort = 6
MSComm1.PortOpen = True
End If
End Sub
Private Sub Combo2_Click()
Select Case Combo2.Text
Case "1200"
MSComm1.Settings = "1200,n,8,1"
Case "2400"
MSComm1.Settings = "2400,n,8,1"
Case "4800"
MSComm1.Settings = "4800,n,8,1"
Case "9600"
MSComm1.Settings = "19200,n,8,1"
End Select
End Sub
Private Sub Form_Load()
MSComm1.PortOpen = True
guan = "关"
kai = "开"
Text1.Text = guan
Text2.Text = guan
Text3.Text = guan
Text4.Text = guan
Text5.Text = "全关"
End Sub
Private Sub Command1_Click()
MSComm1.Output = "A"
Text1.Text = kai
Text1.ForeColor = &HFF&
Text7.ForeColor = &HFF&
Text7.Text = "一:" + kai + " 二:" + Text2.Text + Chr(13) + Chr(10) + "三:" + Text3.Text + " 四:" + Text4.Text
End Sub
Private Sub Command2_Click()
MSComm1.Output = "B"
Text2.ForeColor = &HFF&
Text2.Text = kai
Text7.ForeColor = &HFF&
Text7.Text = "一:" + Text1.Text + " 二:" + kai + Chr(13) + Chr(10) + "三:" + Text3.Text + " 四:" + Text4.Text
End Sub
Private Sub Command3_Click()
MSComm1.Output = "C"
Text3.ForeColor = &HFF&
Text3.Text = kai
Text7.ForeColor = &HFF&
Text7.Text = "一:" + Text1.Text + " 二:" + Text2.Text + Chr(13) + Chr(10) + "三:" + kai + " 四:" + Text4.Text
End Sub
Private Sub Command4_Click()
MSComm1.Output = "D"
Text4.ForeColor = &HFF&
Text4.Text = kai
Text7.ForeColor = &HFF&
Text7.Text = "一:" + Text1.Text + " 二:" + Text2.Text + Chr(13) + Chr(10) + "三:" + Text3.Text + " 四:" + kai
End Sub
Private Sub Command9_Click()
MSComm1.Output = "K"
Text5.ForeColor = &HFF&
Text1.ForeColor = &HFF&
Text2.ForeColor = &HFF&
Text3.ForeColor = &HFF&
Text4.ForeColor = &HFF&
Text1.Text = kai
Text2.Text = kai
Text3.Text = kai
Text4.Text = kai
Text5.Text = "全开"
Text7.ForeColor = &HFF&
Text7.Text = "一:" + kai + " 二:" + kai + Chr(13) + Chr(10) + "三:" + kai + " 四:" + kai
End Sub
Private Sub Command11_Click()
Unload Me
End Sub
Private Sub Command5_Click()
MSComm1.Output = "a"
Text1.Text = guan
Text1.ForeColor = &HFF00&
Text7.ForeColor = &HFF&
Text7.Text = "一:" + guan + " 二:" + Text2.Text + Chr(13) + Chr(10) + "三:" + Text3.Text + " 四:" + Text4.Text
End Sub
Private Sub Command6_Click()
MSComm1.Output = "b"
Text2.Text = guan
Text2.ForeColor = &HFF00&
Text7.ForeColor = &HFF&
Text7.Text = "一:" + Text1.Text + " 二:" + guan + Chr(13) + Chr(10) + "三:" + Text3.Text + " 四:" + Text4.Text
End Sub
Private Sub Command7_Click()
MSComm1.Output = "c"
Text3.Text = guan
Text3.ForeColor = &HFF00&
Text7.ForeColor = &HFF&
Text7.Text = "一:" + Text1.Text + " 二:" + Text2.Text + Chr(13) + Chr(10) + "三:" + guan + " 四:" + Text4.Text
End Sub
Private Sub Command8_Click()
MSComm1.Output = "d"
Text4.Text = guan
Text4.ForeColor = &HFF00&
Text7.ForeColor = &HFF&
Text7.Text = "一:" + Text1.Text + " 二:" + Text2.Text + Chr(13) + Chr(10) + "三:" + Text3.Text + " 四:" + guan
End Sub
Private Sub Command10_Click()
MSComm1.Output = "k"
Text5.ForeColor = &HFF00&
Text5.Text = "全关"
Text1.ForeColor = &HFF00&
Text2.ForeColor = &HFF00&
Text3.ForeColor = &HFF00&
Text4.ForeColor = &HFF00&
Text1.Text = guan
Text2.Text = guan
Text3.Text = guan
Text4.Text = guan
Text7.ForeColor = &HFF00&
Text7.Text = "一:" + guan + " 二:" + guan + Chr(13) + Chr(10) + "三:" + guan + " 四:" + guan
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -