?? form15.frm
字號:
VERSION 5.00
Object = "{648A5603-2C6E-101B-82B6-000000000014}#1.1#0"; "MSCOMM32.OCX"
Begin VB.Form Form15
BackColor = &H00FFC0C0&
Caption = "強迫置位/復(fù)位"
ClientHeight = 6105
ClientLeft = 60
ClientTop = 435
ClientWidth = 9855
FillColor = &H0000FFFF&
LinkTopic = "Form15"
ScaleHeight = 6105
ScaleWidth = 9855
StartUpPosition = 2 '屏幕中心
Begin MSCommLib.MSComm MSComm1
Left = 4440
Top = 120
_ExtentX = 1005
_ExtentY = 1005
_Version = 393216
DTREnable = -1 'True
End
Begin VB.Frame Frame1
BackColor = &H00FFC0FF&
Caption = "強迫置位/復(fù)位"
BeginProperty Font
Name = "楷體_GB2312"
Size = 12
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 4455
Left = 480
TabIndex = 0
Top = 720
Width = 8415
Begin VB.CommandButton Cmd2
BackColor = &H00C0C0FF&
Caption = "復(fù)位"
BeginProperty Font
Name = "楷體_GB2312"
Size = 12
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 6000
Style = 1 'Graphical
TabIndex = 10
Top = 3480
Width = 1695
End
Begin VB.CommandButton Cmd1
BackColor = &H00C0C0FF&
Caption = "置位"
BeginProperty Font
Name = "楷體_GB2312"
Size = 12
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 6000
Style = 1 'Graphical
TabIndex = 9
Top = 2640
Width = 1695
End
Begin VB.TextBox Txt4
Height = 375
Left = 2160
TabIndex = 8
Top = 3360
Width = 2775
End
Begin VB.TextBox Txt3
Height = 375
Left = 2160
TabIndex = 7
Top = 2400
Width = 1935
End
Begin VB.TextBox Txt2
Height = 375
Left = 2160
TabIndex = 6
Top = 1560
Width = 1935
End
Begin VB.TextBox Txt1
Height = 375
Left = 2160
TabIndex = 5
Top = 360
Width = 1935
End
Begin VB.Label Label6
BackStyle = 0 'Transparent
Caption = "指示燈,藍(lán)為正常,紅為不正常"
BeginProperty Font
Name = "楷體_GB2312"
Size = 12
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00FF0000&
Height = 495
Left = 5040
TabIndex = 12
Top = 1920
Width = 3255
End
Begin VB.Label Label5
BackStyle = 0 'Transparent
Caption = "數(shù)據(jù)區(qū)說明:LR(LR),CIO(IR/SR),HR(HR),AR(AR),TIM(TC)"
BeginProperty Font
Name = "楷體_GB2312"
Size = 12
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H000000FF&
Height = 495
Left = 240
TabIndex = 11
Top = 960
Width = 5415
End
Begin VB.Shape Shape1
BackColor = &H00C0C0C0&
BackStyle = 1 'Opaque
FillColor = &H0000FFFF&
FillStyle = 0 'Solid
Height = 1215
Left = 6000
Shape = 3 'Circle
Top = 360
Width = 1575
End
Begin VB.Label Label4
BackStyle = 0 'Transparent
Caption = "接收的字節(jié)"
BeginProperty Font
Name = "楷體_GB2312"
Size = 12
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H000000FF&
Height = 375
Left = 240
TabIndex = 4
Top = 3480
Width = 1455
End
Begin VB.Label Label3
BackStyle = 0 'Transparent
Caption = "強迫置位/復(fù)位的位"
BeginProperty Font
Name = "楷體_GB2312"
Size = 12
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H000000FF&
Height = 615
Left = 240
TabIndex = 3
Top = 2400
Width = 1575
End
Begin VB.Label Label2
BackStyle = 0 'Transparent
Caption = "強迫置位/復(fù)位通道號"
BeginProperty Font
Name = "楷體_GB2312"
Size = 12
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H000000FF&
Height = 495
Left = 240
TabIndex = 2
Top = 1560
Width = 1695
End
Begin VB.Label Label1
BackStyle = 0 'Transparent
Caption = "強迫置位/復(fù)位數(shù)據(jù)區(qū)"
BeginProperty Font
Name = "楷體_GB2312"
Size = 12
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H000000FF&
Height = 495
Left = 240
TabIndex = 1
Top = 360
Width = 1815
End
End
End
Attribute VB_Name = "Form15"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Public Function fcs(ByVal inputstr As String) As String
Dim slen, i, xorresult As Integer
Dim tempfcs As String
slen = Len(inputstr)
xorresult = 0
For i = 1 To slen
xorresult = xorresult Xor Asc(Mid$(inputstr, i, 1))
Next i
tempfcs = Hex$(xorresult)
If Len(tempfcs) = 1 Then tempfcs = "0" + tempfcs
fcs = tempfcs
End Function
Private Sub Cmd1_Click()
Dim A As String
Dim B As String
Dim C As String
Dim tp As String
Dim X As String
If Txt1.Text = "" Then
X = MsgBox("地址不能為空", 16)
Exit Sub
End If
If Txt2.Text = "" Then
X = MsgBox("字節(jié)數(shù)不能為空", 16)
Exit Sub
End If
If Txt3.Text = "" Then
X = MsgBox("位數(shù)據(jù)不能為空", 16)
Exit Sub
End If
MSComm1.InBufferCount = 0
MSComm1.InputLen = 0
If MSComm1.PortOpen = False Then
MSComm1.PortOpen = True
End If
tp = "@00KS"
A = tp + Txt1.Text + Txt2.Text + Txt3.Text + fcs(tp + Txt1.Text + Txt2.Text + Txt3.Text) + "*" + Chr$(13)
If MSComm1.PortOpen = False Then
MSComm1.PortOpen = True
End If
MSComm1.Output = A
Do
DoEvents
Loop Until MSComm1.InBufferCount >= 10
B = MSComm1.Input
Txt4.Text = B
C = Mid((B), 6, 2)
If C = "00" Then
Shape1.FillColor = vbBlue: X = MsgBox("通訊正常", 16)
Else: Shape1.FillColor = vbRed: X = MsgBox("通訊不正常", 16)
End If
Shape1.FillColor = vbYellow
End Sub
Private Sub CMD2_Click()
Dim A As String
Dim B As String
Dim C As String
Dim tp As String
Dim X As String
If Txt1.Text = "" Then
X = MsgBox("地址不能為空", 16)
Exit Sub
End If
If Txt2.Text = "" Then
X = MsgBox("字節(jié)數(shù)不能為空", 16)
Exit Sub
End If
If Txt3.Text = "" Then
X = MsgBox("位數(shù)據(jù)不能為空", 16)
Exit Sub
End If
MSComm1.InBufferCount = 0
MSComm1.InputLen = 0
If MSComm1.PortOpen = False Then
MSComm1.PortOpen = True
End If
tp = "@00KR"
A = tp + Txt1.Text + Txt2.Text + Txt3.Text + fcs(tp + Txt1.Text + Txt2.Text + Txt3.Text) + "*" + Chr$(13)
If MSComm1.PortOpen = False Then
MSComm1.PortOpen = True
End If
MSComm1.Output = A
Do
DoEvents
Loop Until MSComm1.InBufferCount >= 10
B = MSComm1.Input
Txt4.Text = B
C = Mid((B), 6, 2)
If C = "00" Then
Shape1.FillColor = vbBlue: X = MsgBox("通訊正常", 16)
Else: Shape1.FillColor = vbRed: X = MsgBox("通訊不正常", 16)
End If
Shape1.FillColor = vbYellow
End Sub
Private Sub Form_Load()
MSComm1.CommPort = 3
MSComm1.Settings = "9600,E,7,2"
MSComm1.InputLen = 0
End Sub
Private Sub Form_Unload(Cancel As Integer)
Form2.Enabled = True
Form2.Show
Unload Me
End Sub
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -