| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 639 人关注过本帖
标题:请哪位高手帮我注释一下下面的程序吧!
只看楼主 加入收藏
jiangchengli003
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2008-5-26
收藏
 问题点数:0 回复次数:1 
请哪位高手帮我注释一下下面的程序吧!
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)
     outstring = Change_S(outstring, 1)
  For i = 1 To Len(outstring)
      MSComm1.Output = Mid(outstring, i, 1)
  Next i
  If outstring = "" Then
    MsgBox "无发送数据!", 52, "提示"
  Else

  End If
End If
End Sub

Private Sub Command2_Click()
   
   If MSComm1.PortOpen = False Then
      MsgBox "串口未打开", 52, "提示"
    Else
      On Error Resume Next
      Text1.Text = MSComm1.Input
    End If
     
End Sub

Private Sub Command3_Click()
Text1.Text = ""
Text2.Text = ""
End Sub

Private Sub Command5_Click()
End
End Sub

Private Sub Command6_Click()
Dim t As Integer
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)
   ElseIf t >= 65 And t <= 90 Then
      s = Chr(t)
   ElseIf t >= 97 And t <= 122 Then
      s = Chr(t)
   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)
   ElseIf t >= 65 And t <= 90 Then
      Change_R = Chr(t)
   ElseIf t >= 97 And t <= 122 Then
      Change_R = Chr(t)
   End If

End Function
搜索更多相关主题的帖子: 注释 
2008-06-04 21:41
lzn3303768
Rank: 1
来 自:土星
等 级:新手上路
帖 子:55
专家分:0
注 册:2008-5-24
收藏
得分:0 
串口操作嘛
2008-06-04 22:23
快速回复:请哪位高手帮我注释一下下面的程序吧!
数据加载中...
 
   



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

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