都知道 - 都知道 - 知识图谱网站

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

Public Function Comm_Getdataintime(ByVal Dutime As Long, Buf_Ret As Variant, ByVal Num As Integer, Group As Integer) Dim get1 As Long Dim get2 As Long Dim get3 As Long Dim Tempbuf As Variant get1 = GetTickCount() Do While FrmComm.MSComm(Group).InBufferCount < Num get2 = GetTickCount get3 = get2 - get1 If get3 > Dutime Then Exit Do Loop Tempbuf = FrmComm.MSComm(Group).Input Buf_Ret = Tempbuf 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