| 发表于:2007-04-13 20:38:18 楼主 |
public function strtohex(byval s as string) as string on error resume next dim bytearr() as byte bytearr = strconv(s, vbfromunicode) dim temps as string dim temp as byte dim i as long dim outs as string for i = 0 to ubound(bytearr) temp = bytearr(i) temps = hex(temp) temps = right( "00 " & temps, 2) outs = outs & temps next strtohex = outs end function private sub udppeera_dataarrival(byval bytestotal as long) dim strdata as string dim inbyte() as byte dim i as integer udppeera.getdata strdata inbyte() = strtohex(strdata) txtoutput.text = txtoutput.text & cstr( " < < ") & cstr(inbyte) strdata = " " end sub 以上程序是本人在做通讯测试时用的,vb在接收到十六进制数据之后winsock将其看成是ascii码字符,用strtohex就是将程序收到的字符转换成实际接收十六进制.现在有个问题是,在0~128(即00h~80h)以及255(0ffh)时,可以正确转换,但在81h~0feh这些字符段时无法识别,好象就是我的vb里的ascii码字符就是0~128似的,而不是255个!请问高手问题出在哪里,谢谢先!!!! |
|
|
|
|