| 发表于:2007-02-27 18:25:14 楼主 |
我用vb的那个串口控件向串口发数据 例如发 "a5 " 十六进制数,一个字节 用串口助手监视的结果是a和5的ascii码 最后在网上找了一段程序 处理以后再发送 用串口助手监视的结果又变成了0a 05 请问错在哪里呀 急 急 急 private sub senddata() dim rdata as string rdata=change_s( "a5 ") comm.output=rdata '串口控件发送 end sub private function change_s(strs as string) as string dim i as integer, t as integer dim s as string, m as string, temp as string, lishi as string m = strs 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 - 48) elseif t > = 65 and t <= 70 then s = chr(t - 55) elseif t > = 97 and t <= 102 then s = chr(t - 87) end if temp = temp & s next i change_s = temp end function |
|
|
|
|