debug.print的疑惑
大虾们你们好!
小弟有一个小程序,在Byte_R_W.bas模块中一定要有debug.print才能正常运行,打包或者生成exe后则无法运行。
请各大虾帮忙解惑,不胜感激
附上程序
监控1.rar
(3.35 KB)
Public Function Byte_Read(Comm As MSComm, sAddr As String) As String Dim STX As String Dim Cmd As String Dim Addr As String Dim ByteNum As String Dim ETX As String Dim CheckString As String Dim CheckSum As String Dim CmdCode As String Dim Sum As Integer Dim n As Integer Dim delay_time As Double Dim delay_start As Double Dim delay_chk As Double Dim tmp As String STX = Chr(2) Cmd = "0" Addr = UCase(sAddr) ByteNum = "03" ETX = Chr(3) CheckString = Cmd + Addr + ByteNum + ETX For n = 1 To Len(CheckString) Sum = Sum + Asc(Mid$(CheckString, n, 1)) Next n CheckSum = Right$(Hex(Sum), 2) CmdCode = STX + Cmd + Addr + ByteNum + ETX + CheckSum Comm.PortOpen = True Comm.Output = CmdCode 'DoEvents 'Debug.Print "CMDCODE="; CmdCode ' Do While Len(tmp) < 6 ' tmp = tmp + Comm.Input ' Debug.Print "tmp="; Comm.Input ' n = n + 1 'If n >= 100 Then ' Comm.PortOpen = False 'Exit Function 'End If 'Debug.Print 'DoEvents ' Loop delay_time = 0.1 delay_start = Timer Do delay_chk = delay_start + delay_time Loop Until Timer > delay_chk tmp = Comm.Input tmp = Mid$(tmp, 6, 2) + Mid$(tmp, 4, 2) + Mid$(tmp, 2, 2) Byte_Read = Hex2Bin(tmp) Comm.PortOpen = False End Function 各位大虾: 谢谢你们的帮忙; 近日XD在一本台湾的书上看到了一些例子,后将代码修改后,测试运行速度快了很多,运转也正常; 但XD还是想不通为何旧程度里要用debug.print才能运行,谢谢