📄 form.frm
字号:
VERSION 5.00
Object = "{648A5603-2C6E-101B-82B6-000000000014}#1.1#0"; "MSCOMM32.OCX"
Begin VB.Form Form1
Caption = "洗衣机控制程序"
ClientHeight = 5775
ClientLeft = 60
ClientTop = 450
ClientWidth = 8610
LinkTopic = "Form1"
ScaleHeight = 5775
ScaleWidth = 8610
StartUpPosition = 3 '窗口缺省
Begin VB.OptionButton Option4
Caption = "串口洗衣机4"
Height = 495
Left = 480
TabIndex = 15
Top = 1800
Width = 1455
End
Begin VB.OptionButton Option3
Caption = "串口洗衣机3"
Height = 495
Left = 480
TabIndex = 14
Top = 1320
Width = 1455
End
Begin VB.OptionButton Option2
Caption = "串口洗衣机2"
Height = 495
Left = 480
TabIndex = 13
Top = 840
Width = 1455
End
Begin VB.OptionButton Option1
Caption = "串口洗衣机1"
Height = 495
Left = 480
TabIndex = 12
Top = 360
Width = 1455
End
Begin VB.CommandButton Command7
Caption = "连接设备"
Height = 495
Left = 3600
TabIndex = 7
Top = 480
Width = 975
End
Begin MSCommLib.MSComm MSComm1
Left = 7920
Top = 5160
_ExtentX = 1005
_ExtentY = 1005
_Version = 393216
DTREnable = -1 'True
End
Begin VB.CommandButton Command5
Caption = "启动洗衣机"
Height = 375
Left = 3480
TabIndex = 6
Top = 1440
Width = 1335
End
Begin VB.CommandButton Command4
Caption = "重复次数"
Height = 375
Left = 3600
TabIndex = 5
Top = 3600
Width = 975
End
Begin VB.CommandButton Command3
Caption = "循环圈数"
Height = 375
Left = 3600
TabIndex = 4
Top = 3120
Width = 975
End
Begin VB.CommandButton Command2
Caption = "洗衣强度"
Height = 375
Left = 3600
TabIndex = 3
Top = 2520
Width = 975
End
Begin VB.CommandButton Command1
Caption = "水位设置"
Height = 375
Left = 3600
TabIndex = 2
Top = 2040
Width = 975
End
Begin VB.Frame Frame2
Caption = "Frame2"
Height = 2535
Left = 5280
TabIndex = 0
Top = 120
Width = 3135
Begin VB.TextBox Text2
Height = 2175
Left = 120
TabIndex = 1
Text = "Text2"
Top = 240
Width = 2895
End
End
Begin VB.Label Label4
Caption = "2"
Height = 375
Left = 4800
TabIndex = 11
Top = 3600
Width = 255
End
Begin VB.Label Label3
Caption = "3"
Height = 375
Left = 4800
TabIndex = 10
Top = 3120
Width = 255
End
Begin VB.Label Label2
Caption = "强"
Height = 255
Left = 4800
TabIndex = 9
Top = 2640
Width = 255
End
Begin VB.Label Label1
Caption = "中"
Height = 255
Left = 4800
TabIndex = 8
Top = 2160
Width = 255
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim wat_lv As Byte
Dim health As Byte
Dim cycle As Byte
Dim replay As Byte
Dim flag_start As Byte
Dim PortValue As Integer
Dim Send_buff() As String
Private Sub Command1_Click()
'加水位
wat_lv = wat_lv + 1
If wat_lv = 4 Then
wat_lv = 1
End If
flag_buff = y
Select Case wat_lv
Case 1
Label1.Caption = "低"
Case 2
Label1.Caption = "中"
Case 3
Label1.Caption = "高"
End Select
' MSComm1.Output = "w" & Str(wat_lv)
MSComm1.Output = "w" & Str(wat_lv)
End Sub
Private Sub Command2_Click()
'强度
health = health + 1
If health = 3 Then
health = 1
End If
Select Case health
Case 1
Label2.Caption = "弱"
Case 2
Label2.Caption = "强"
End Select
MSComm1.Output = "h" & Str(health)
End Sub
Private Sub Command3_Click()
'循环圈数
cycle = cycle + 1
If cycle = 10 Then
cycle = 1
End If
Label3.Caption = cycle
MSComm1.Output = "c" & Str(cycle)
End Sub
Private Sub Command4_Click()
'重复次数
replay = replay + 1
If replay = 6 Then
replay = 1
End If
Label4.Caption = replay
MSComm1.Output = "r" & Str(replay)
End Sub
Private Sub Command5_Click()
'启动洗衣机
Select Case flag_start
Case 0
Command5.Caption = "关闭洗衣机"
flag_start = 1
Case 1
Command5.Caption = "启动洗衣机"
flag_start = 0
End Select
MSComm1.Output = "s" & Str(flag_start)
End Sub
Private Sub Command7_Click()
MSComm1.PortOpen = Not MSComm1.PortOpen
If MSComm1.PortOpen = True Then
Command7.Caption = "断开串口"
Else
Command7.Caption = "连接串口"
End If
End Sub
Private Sub Form_Load()
Text2.Text = " "
MSComm1.CommPort = 2
MSComm1.Settings = "9600,n,8,1"
MSComm1.InputLen = 0
MSComm1.InBufferSize = 512
MSComm1.InBufferCount = 0
MSComm1.OutBufferSize = 512
MSComm1.OutBufferCount = 0
MSComm1.RThreshold = 2
MSComm1.SThreshold = 0
flag_start = 0
wat_lv = 2 '水位高度
cycle = 3 '电动机循环次数
replay = 2 '反复洗衣次数
health = 2 '强度
End Sub
Public Function output_data(fla As String)
MSComm1.Output = fla
End Function
Private Sub MSComm1_OnComm()
Select Case MSComm1.CommEvent
Case comEvReceive
' Send_buff = MSComm1.Input '中断赋值
' Select Case flag_start
' Case 0
' Command5.Caption = "关闭洗衣机"
' flag_start = 1
' Case 1
' Command5.Caption = "启动洗衣机"
' flag_start = 0
' End Select
Case Else
End Select
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -