- 1、本文档共8页,可阅读全部内容。
- 2、有哪些信誉好的足球投注网站(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
手写板串行通信检测程序概要
手写板串行通信检测?Option Explicit
? ?
? Private Const WM_USER = H400
? Private Const EM_SETTARGETDEVICE = (WM_USER + 72)
? ?
? Private Declare Function GetDC Lib user32 (ByVal hWnd As Long) As Long
? Private Declare Function SendMessage Lib user32 Alias SendMessageA _
? (ByVal hWnd As Long, _
? ByVal wMsg As Long, _
? ByVal wParam As Long, _
? lParam As Any) As Long
? ?
? Public Sub AutoSwitchLine(ByRef RichText As RichTextBox, ByVal bSwitch As Boolean)
? ? If bSwitch Then
? ? 设置 ? RichTextBox ? 自动换行
? ? ? ? Call SendMessage(RichText.hWnd, EM_SETTARGETDEVICE, _
? ? ? ? ? ? GetDC(RichText.hWnd), RichText.Width / 15)
? ? ? ? If RichText.RightMargin = 0 Then
? ? ? ? ? ? RichText.RightMargin = 1
? ? ? ? Else
? ? ? ? ? ? RichText.RightMargin = 0
? ? ? ? End If
? ? Else
? ? 设置 ? RichTextBox ? 不自动换行
? ? ? ? Call SendMessage(RichText.hWnd, EM_SETTARGETDEVICE, 0, 1)
? ? End If
? End Sub
?
Private Sub Form_Load()
?AutoSwitchLine RichTextBox1, True
? ? ?Dim i As Integer
? ? StatusBar1.Panels(2).Text = 日期:时间 Now ?初值赋给Combo_FontSize
End Sub
Private Sub MSComm1_OnComm()
? ? CommPort = 1
? ? MSComm.Settings = 9600,N,8,1
? ? MSComm.InBufferSize = 40 ? ? ? ? ?设置缓冲区接收数据为40字节
? ? MSComm.InBufferCount = 0
? ? MSComm.InputMode = comInputModeBinary ? 二进制方式
? ? MSComm.InputLen = 0 ? ? ? ? ? ? ? ? ?每次读入缓冲区所有字符
? ? MSComm.PortOpen = True ? ? ? ? ? 打开串口
End Sub
Private Sub RichTextBox1_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
StatusBar1.Panels(1).Text = x: x ,y: y ? ? 将光标(x,y)赋给状态栏的第1个窗格
End Sub
Private Sub Timer1_Timer()
StatusBar1.Panels(2).Text = 日期:时间 Now
End Sub
Private Sub Timer2_Timer()
Dim InByte() As Byte
?If MSComm1.InBufferCount 0 Then ?判断串口是否有数据输入
?InByte = MSComm1.Input ? ? ? ? ? ?将串口数据读取到InByte
?Dim j As Long
?Dim a As Integer
?Dim b As Integer
?
For j = 0 To UBound(InByte) ? ? ? ? ? 循环到指针上标
? ? ? ? ? ? a = (InByte(j) Mod 16) ? ?将读取的数据分解成十六进制数据显示
? ? ? ? ? ? b = ((InByte(j) - a) / 16)
? ? ? ? ? ? ? ? Select Case b
? ? ? ? ?
文档评论(0)