?? 串行通信_數(shù)據(jù)傳輸_發(fā)送端f.frm
字號:
VERSION 5.00
Object = "{648A5603-2C6E-101B-82B6-000000000014}#1.1#0"; "MSCOMM32.OCX"
Begin VB.Form Form1
Appearance = 0 'Flat
BackColor = &H80000005&
Caption = "數(shù)據(jù)傳輸"
ClientHeight = 3645
ClientLeft = 60
ClientTop = 345
ClientWidth = 3060
LinkTopic = "Form1"
ScaleHeight = 3645
ScaleWidth = 3060
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton Command2
Caption = "結(jié) 束"
Height = 375
Left = 720
TabIndex = 3
Top = 2880
Width = 1815
End
Begin VB.TextBox Text1
Appearance = 0 'Flat
Height = 975
Left = 360
MultiLine = -1 'True
TabIndex = 0
Text = "串行通信_數(shù)據(jù)傳輸_發(fā)送端F.frx":0000
Top = 600
Width = 2415
End
Begin VB.CommandButton Command1
Caption = "發(fā) 送"
Height = 375
Left = 720
TabIndex = 1
Top = 1920
Width = 1815
End
Begin MSCommLib.MSComm MSComm1
Left = 1440
Top = 2280
_ExtentX = 1005
_ExtentY = 1005
_Version = 393216
DTREnable = -1 'True
End
Begin VB.Label Label1
Alignment = 2 'Center
Appearance = 0 'Flat
BackColor = &H80000005&
Caption = "放送數(shù)據(jù)區(qū)"
ForeColor = &H80000008&
Height = 255
Left = 600
TabIndex = 2
Top = 240
Width = 1815
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'發(fā)送數(shù)據(jù)
'在代碼中凡以****作為注釋的,在以后的實時通信工程中必須刪除
Option Explicit
Dim Cst() As Byte
Private Sub Form_Load()
Cst = "this is test string"
MSComm1.CommPort = 1 '指定Com1口作為通信端口
MSComm1.PortOpen = True '打開串行端口
MSComm1.Settings = "9600,N,8,1"
MSComm1.InputLen = 0 'default
MSComm1.InputMode = comInputModeBinary
MSComm1.OutBufferCount = 0
Text1.Text = Cst
MSComm1.Output = Cst '將輸入字符串寫入發(fā)送緩沖區(qū)
Debug.Print MSComm1.OutBufferCount, MSComm1.OutBufferSize
End Sub
Private Sub Command1_click()
Dim aaa(100) As Byte
aaa(0) = Hex(104)
'aaa(1) = Hex(161)
Debug.Print aaa
Debug.Print aaa(0)
MSComm1.Output = aaa ' Cst '將輸入字符串寫入發(fā)送緩沖區(qū)
Debug.Print MSComm1.OutBufferCount, MSComm1.OutBufferSize
'如果有串口連線作實時傳輸,下面這條語句是不用的
'將發(fā)送字符串也送到注冊數(shù)據(jù)庫
' SaveSetting "TestMSComm", "SEC1", "Key1", strOut '****
End Sub
Private Sub Command2_Click()
MSComm1.PortOpen = False '關(guān)閉端口
Unload Me
End Sub
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -