?? form1.frm
字號:
VERSION 5.00
Object = "{648A5603-2C6E-101B-82B6-000000000014}#1.1#0"; "MSCOMM32.OCX"
Begin VB.Form Form1
BackColor = &H00C0C0C0&
Caption = "串口調試"
ClientHeight = 5445
ClientLeft = 60
ClientTop = 345
ClientWidth = 8190
BeginProperty Font
Name = "華文隸書"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Icon = "Form1.frx":0000
LinkTopic = "Form1"
ScaleHeight = 5445
ScaleWidth = 8190
StartUpPosition = 3 '窗口缺省
Begin VB.ComboBox Combo1
BeginProperty Font
Name = "宋體"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 300
ItemData = "Form1.frx":030A
Left = 6480
List = "Form1.frx":0314
TabIndex = 10
Text = "十六進制"
Top = 240
Width = 1215
End
Begin VB.CommandButton Command6
Caption = "串口關閉"
BeginProperty Font
Name = "宋體"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 1080
TabIndex = 9
Top = 4920
Width = 1095
End
Begin MSCommLib.MSComm MSComm1
Left = 7440
Top = 4800
_ExtentX = 1005
_ExtentY = 1005
_Version = 393216
DTREnable = -1 'True
End
Begin VB.CommandButton Command5
Caption = "退 出(&Q)"
BeginProperty Font
Name = "宋體"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 5760
TabIndex = 8
Top = 4920
Width = 1215
End
Begin VB.TextBox Text2
BeginProperty Font
Name = "宋體"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 1095
Left = 480
MaxLength = 5000
MultiLine = -1 'True
ScrollBars = 2 'Vertical
TabIndex = 6
Top = 3600
Width = 7095
End
Begin VB.TextBox Text1
BeginProperty Font
Name = "宋體"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 1815
Left = 480
MaxLength = 10000
MultiLine = -1 'True
ScrollBars = 2 'Vertical
TabIndex = 4
Top = 1080
Width = 7095
End
Begin VB.CommandButton Command4
Caption = "設 置(&E)"
BeginProperty Font
Name = "宋體"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 4680
TabIndex = 3
Top = 240
Width = 1335
End
Begin VB.CommandButton Command3
Caption = "清 除(&C)"
BeginProperty Font
Name = "宋體"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 3240
TabIndex = 2
Top = 240
Width = 1335
End
Begin VB.CommandButton Command2
Caption = "接 收(&R)"
BeginProperty Font
Name = "宋體"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 1800
TabIndex = 1
Top = 240
Width = 1335
End
Begin VB.CommandButton command1
Caption = "發 送(&S)"
BeginProperty Font
Name = "宋體"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Index = 1
Left = 480
TabIndex = 0
Top = 240
Width = 1215
End
Begin VB.Line Line10
BorderColor = &H00FFFF80&
X1 = 480
X2 = 360
Y1 = 3480
Y2 = 3480
End
Begin VB.Line Line9
BorderColor = &H00FFFF80&
X1 = 360
X2 = 360
Y1 = 3480
Y2 = 4800
End
Begin VB.Line Line8
BorderColor = &H00FFFF80&
X1 = 360
X2 = 7680
Y1 = 4800
Y2 = 4800
End
Begin VB.Line Line7
BorderColor = &H00FFFF80&
X1 = 7680
X2 = 7680
Y1 = 4800
Y2 = 3480
End
Begin VB.Line Line6
BorderColor = &H00FFFF80&
X1 = 1440
X2 = 7680
Y1 = 3480
Y2 = 3480
End
Begin VB.Line Line5
BorderColor = &H00FFFF80&
X1 = 480
X2 = 360
Y1 = 960
Y2 = 960
End
Begin VB.Line Line4
BorderColor = &H00FFFF80&
X1 = 360
X2 = 360
Y1 = 960
Y2 = 3000
End
Begin VB.Line Line3
BorderColor = &H00FFFF80&
X1 = 360
X2 = 7680
Y1 = 3000
Y2 = 3000
End
Begin VB.Line Line2
BorderColor = &H00FFFF80&
X1 = 7680
X2 = 7680
Y1 = 3000
Y2 = 960
End
Begin VB.Line Line1
BorderColor = &H00FFFF80&
X1 = 1440
X2 = 7680
Y1 = 960
Y2 = 960
End
Begin VB.Label Label2
BackStyle = 0 'Transparent
Caption = "發送數據"
BeginProperty Font
Name = "宋體"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Left = 600
TabIndex = 7
Top = 3360
Width = 735
End
Begin VB.Label Label1
BackStyle = 0 'Transparent
Caption = "接收回顯"
BeginProperty Font
Name = "宋體"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Left = 600
TabIndex = 5
Top = 840
Width = 855
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim Instring As String, jc As Integer
Private Sub command1_Click(Index As Integer)
Dim outstring As String, i As Integer
MSComm1.OutBufferCount = 0
If MSComm1.PortOpen = False Then
MsgBox "串口未打開", 52, "提示"
Else
outstring = Trim(Text2.Text)
If Combo1.ListIndex = 1 Then
outstring = Change_S(outstring, Combo1.ListIndex)
ElseIf Combo1.ListIndex = -1 Or Combo1.ListIndex = 0 Then
outstring = Change_S(outstring, 0)
End If
For i = 1 To Len(outstring)
MSComm1.Output = Mid(outstring, i, 1)
Next i
If outstring = "" Then
MsgBox "無發送數據!", 52, "提示"
Else
' Text2.Text = ""
End If
End If
End Sub
Private Sub Command2_Click()
Dim Instring As String, temp As String, i As Integer, xs As Integer
Dim xh As Integer
xh = Combo1.ListIndex
If Combo1.ListIndex = -1 Then
xh = 0
End If
If MSComm1.PortOpen = False Then
MsgBox "串口未打開", 52, "提示"
Else
On Error Resume Next
'輪詢數據
jmp1: Do
DoEvents
Loop Until MSComm1.InBufferCount >= 0
Instring = MSComm1.Input
If xianshi = 0 Then
For i = 1 To Len(Instring)
If i Mod 2 = 0 Then
Text1.Text = Text1.Text & Change_R(Instring, xh) & " "
Else
Text1.Text = Text1.Text & Change_R(Instring, xh)
End If
Next i
Else
For i = 1 To Len(Instring)
If i Mod 8 = 0 Then
Text1.Text = Text1.Text & Change_R(Instring, xh) & " "
Else
Text1.Text = Text1.Text & Change_R(Instring, xh)
End If
Next i
End If
GoTo jmp1
End If
End Sub
Private Sub Command3_Click()
Text1.Text = ""
End Sub
Private Sub Command4_Click()
Form2.Show
End Sub
Private Sub Command5_Click()
End
End Sub
Private Sub Command6_Click()
Dim t As Integer
Dim a As Integer
a = Form2.comport
Select Case a
Case 1
MSComm1.CommPort = 1
Case 2
MSComm1.CommPort = 2
Case 3
MSComm1.CommPort = 3
Case 4
MSComm1.CommPort = 4
End Select
MSComm1.Settings = Form2.comsetting
t = StrComp(Command6.Caption, "串口打開")
If Not t Then
Command6.Caption = "串口關閉"
MSComm1.PortOpen = False
t = 0
Else
Command6.Caption = "串口打開"
MSComm1.PortOpen = True
If comEvReceive Then
MSComm1.InBufferCount = 0
Instring = Instring & MSComm1.Input
End If
End If
Me.Show
End Sub
Private Function Change_S(strs As String, x As Integer) As String
Show
Dim i As Integer, t As Integer
Dim s As String, m As String, temp As String, lishi As String
If x = 0 Then
For i = 1 To Len(strs) Step 3
s = Mid(strs, i, 2)
m = m & s
Next i
ElseIf x = 1 Then
For i = 1 To Len(strs) Step 9
s = Mid(strs, i, 8)
m = m & s
Next i
End If
For i = 1 To Len(m)
lishi = Mid(m, i, 1)
t = Asc(Mid(m, i, 1))
If t >= 48 And t <= 57 Then
s = Chr(t - 48)
ElseIf t >= 65 And t <= 70 Then
s = Chr(t - 55)
ElseIf t >= 97 And t <= 102 Then
s = Chr(t - 87)
End If
temp = temp & s
Next i
Change_S = temp
End Function
Private Function Change_R(strs As String, x As Integer) As String
Show
Dim t As Integer
Dim s As String, m As String, temp As String
t = Asc(strs)
If t >= 48 And t <= 57 Then
Change_R = Chr(t + 48)
ElseIf t >= 65 And t <= 70 Then
Change_R = Chr(t + 56)
ElseIf t >= 97 And t <= 102 Then
Change_R = Chr(t + 88)
End If
Print Change_R
'If x = 0 Then
'ElseIf x = 1 Then
' For i = 0 To Len(strs) Step 8
' s = Mid(strs, i, 8) & " "
' m = m & s
' Next i
'End If
'Change_R = m
End Function
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -