一段vb程序看不太懂,高手请指点一下。

Public Function Comm_Getdataintime(ByVal Dutime As Long, Buf_Ret As Variant, ByVal Num As Integer, Group As Integer)<br />Dim get1 As Long<br />Dim get2 As Long<br />Dim get3 As Long<br />Dim Tempbuf As Variant<br /><br />get1 = GetTickCount()<br />Do While FrmComm.MSComm(Group).InBufferCount &lt; Num<br /> get2 = GetTickCount<br /> get3 = get2 - get1<br /> If get3 &gt; Dutime Then Exit Do<br />Loop<br />Tempbuf = FrmComm.MSComm(Group).Input<br />Buf_Ret = Tempbuf<br /><br />End Function
get3 = get2 - get1’两个时间差
If get3 > Dutime Then Exit Do‘超时,退出do while
Loop
Tempbuf = FrmComm.MSComm(Group).Input
Buf_Ret = Tempbuf
get1 = GetTickCount()'从操作系统启动到现在所经过(elapsed)的毫秒数
Do While FrmComm.MSComm(Group).InBufferCount < Num
get2 = GetTickCount ‘再取一次
get3 = get2 - get1’两个时间差
If get3 > Dutime Then Exit Do‘超时,退出do while
Loop
Tempbuf = FrmComm.MSComm(Group).Input
Buf_Ret = Tempbuf
get1 = GetTickCount()'从操作系统启动到现在的毫秒数
Do While FrmComm.MSComm(Group).InBufferCount < Num 一直到串口中的数据长度超过了指定值 结束循环
get2 = GetTickCount ‘再取一次
get3 = get2 - get1’两个时间差
If get3 > Dutime Then Exit Do‘超时,退出do while
Loop
Tempbuf = FrmComm.MSComm(Group).Input将串口中数据赋值给 tempbuf
Buf_Ret = Tempbuf
http://zhidao.baidu.com/question/402543576.html