标题:急!~ 大家帮帮忙!~
只看楼主
teefy
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2008-4-14
 问题点数:0 回复次数:0 
急!~ 大家帮帮忙!~
Option Explicit

Private Sub Command1_Click()
Dim si(1) As Byte
si(0) = &H63
si(1) = &H25
 MSComm1.Output = si
End Sub
Private Sub Form_Load()
MSComm1.Settings = "9600,n,8,1"
= 1
MSComm1.InputLen = 0
MSComm1.InBufferSize = 1024
MSComm1.InBufferCount = 0
MSComm1.RThreshold = 1
MSComm1.SThreshold = 1
MSComm1.PortOpen = True
End Sub
Private Sub MSComm1_OnComm()
Dim sData() As Byte
Dim strBuff As String
Dim i As Integer
Dim strdata As Variant

If = 2 Then
MSComm1.InputLen = 0
strBuff = MSComm1.Input
sData() = strBuff

For i = 0 To UBound(sData)
If Len(Hex(sData(i))) = 1 Then
strdata = strdata & "0" & Hex(sData(i))
Else
strdata = strdata & Hex(sData(i))
End If
Next
 Text1 = strdata
 Call DataClear
 End If

Private Sub Timer1_Timer()
Dim sj(0) As Byte

sj(0) = &H3

MSComm1.Output = sj
End Sub

Public Sub DataClear()
    MSComm1.OutBufferCount = 0
    MSComm1.InBufferCount = 0
  
End Sub

当程序运行时,定时器 定时发送查询地址到单片机 自动回传数据 显示在电脑上 . 我手动按纽发送命令时候  有时候会发生 按纽控制不了的问题  应该就是数据有冲突的问题吧  该怎么解决 很急!~ 谢谢大家  能给点意见 怎么改进
搜索更多相关主题的帖子: Sub Dim Private Byte End 
2008-04-15 09:08



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-209080-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.273661 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved