Vc++代码翻译vb
冰天雪地,裸体跪求,各位大侠把下面这段VC++的翻译成VB代码,小弟不甚感激(小弟我到死也不会忘记你,做鬼也不会放过你)
/*
================================================================================
函数: int MxHexToAscii(unsigned char *hex,char * ascii,int nLength)
功能: 把nLength个字节逐个分解成2*nLength个可见字符。
高4位和低4位分别转换,直接加0x30。
参数:
返回值: 始终为0,表示成功。
================================================================================
*/
int MxHexToAscii(unsigned char *hex,char * ascii,int nLength)
{
int hiByte,loByte;
int i;
for ( i=0;i<nLength;i++)
{
hiByte=(hex[i]>>4)&0x0f;
loByte=hex[i]&0x0f;
ascii[i*2]=(char )(hiByte+48);
ascii[i*2+1]=(char)(loByte+48);
}
return 0;
}
/*
================================================================================
函数: int MxAsciiToHex(char * ascii,unsigned char * hex,int nLength)
功能: 把2*nLength个可见字符逐对合并成nLength个字节。
输入的可见字符要求在0x30和0x3F之间。
参数:
返回值: 0:成功;
-1:数据非法
================================================================================
*/
int MxAsciiToHex(char * ascii,unsigned char * hex,int nLength)
{
int hiByte,loByte;
int i;
for ( i=0;i<nLength;i++)
{
hiByte=ascii[i*2]-48;
if (hiByte<0 || hiByte>15)
return -1;
loByte=ascii[i*2+1]-48;
if (loByte<0 || loByte>15)
return -1;
hex[i]=(unsigned char)(hiByte*16+loByte);
}
return 0;
}
MxHexToAscii(iMyMb,mbchar,256);//把模板数据转从二进制转换到字符串,方便存储
mbchar[512]=0;//加结束符号
mbstr=mbchar;