在线求教 关于串口通讯 oncomm事件,该如何处理

在线求教 关于串口通讯 oncomm事件
PB用ole控件来作串口通讯,读卡片的序列号,现已可以读到序列号了,但不知乍会事,读好后会清空我要求显示的地方,代码如下,请哪位大虾帮忙查看那里出错了,好了忙上给分。ole_1.object.CommPort=ls_com
//ole_1.object.Handshaking=1
ole_1.object.Settings="2400,N,8,1"
ole_1.object.inputmode = 1
ole_1.object.Rthreshold=1
ole_1.object.Inputlen=1
//ole_1.object.portopen= false
if ole_1.object.portopen then
messagebox('注意','端口被占用')
// return
close(this)
ole_1.object.PortOpen= false
end if
ole_1.object.portopen=true

character lchr_temp[]
string ls_temp
long i//,l_len
blob buffer,bufnull
ls_temp = ''
ib_lock=true
do while ole_1.object.InBufferCount >= ole_1.object.RThreshold 
buffer=ole_1.object.input
//ole_1.object.input=bufnull
//ole_1.object.inputlen=0

ib_lock=false
iuo_bit.blob2chararray(buffer,lchr_temp)
//ole_1.object.InBufferCount = 0 
for i = 1 to upperbound(lchr_temp)
if isnull(lchr_temp[i]) then
ls_temp += '00'
else
ls_temp += string(iuo_bit.int2hex(asc(lchr_temp[i])) )
end if
next
//setnull(ole_1.object.input)
loop

// messagebox('',mid(ls_temp,9,8))
for i=1 to 1000
next
sle_1.text = mid(ls_temp,9,8)
//sle_1.event modified()
也就是sle_1.text变为空了在线等着

------解决方案--------------------
mid(ls_temp,9,8)是否有数据

另外是否该函数会被连续执行两次,第一次取到值了,但是紧接着有执行一次取到的值为空值