?? 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 = "循環(huán)圈數"
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()
'循環(huán)圈數
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 '電動機循環(huán)次數
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 + -