简单,多分,
简单,多分,在线等!
char temp[8192];
int len=0;
unsigned short crc=0;
crc = cal_crc(0,temp,len);
code unsigned int crc16_table[256] = {
0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50a5, 0x60c6, 0x70e7,
。。。。。。。。。。。。。。。。。。。。。。。。。。。。。
0x6e17, 0x7e36, 0x4e55, 0x5e74, 0x2e93, 0x3eb2, 0x0ed1, 0x1ef0};
static unsigned short cal_crc(unsigned short s, unsigned char *ptr,
unsigned long len)
{
unsigned short crc;
unsigned char da;
crc = s;
while(len--!=0)
{
da = (unsigned char) (crc > > 8);
crc < <= 8;
crc ^= crc_ta[da^*ptr];
ptr++;
}
return (crc);
}
怎么把这个过程翻译为VB的啊?
------解决方案--------------------
不懂,路过!
------解决方案--------------------
什么语言啊,好像是C之类的东东。正打算学习。。
------解决方案--------------------
网上有现成crc16的vb代码的,你可以搜索一下,我以前下载过
------解决方案--------------------
前面一段是数组定义,比较简单,不翻译了,后面大概如下:
static unsigned short cal_crc(unsigned short s, unsigned char *ptr,
unsigned long len)
{
unsigned short crc;
unsigned char da;
crc = s;
while(len--!=0)
{
da = (unsigned char) (crc > > 8);
crc < <= 8;
crc ^= crc_ta[da^*ptr];
ptr++;
}
return (crc);
}
大概翻译如下(应该有错误,只是直接翻译的,没有经过DEBUG)
Private Declare Sub CopyMemory Lib "kernel32 " Alias "RtlMoveMemory " (pDest As Any, pSrc As Any, ByVal ByteLen As Long)
publisc function cal_crc(byval s as integer, buval ptr as long, byval len1 as long ) as inreger
dim crc as integer
dim da as string *1
dim tmp as string
crc=s
do while len1 <> 0
len1=len1-1
da=cint(crc/256)
crc=crc*256
copymemory tmp, ptr,8
crc= crc xor (da xor tmp)
ptr=ptr+2
loop
end function
------解决方案--------------------
计算 CRC 的模块直接下一个,用不着自己翻译,编程要学会“偷懒”
------解决方案--------------------
TO:wxf0204(网泥www.xmlenz.cn,QQ:21956798)
WallesCai(女人之美,在于蠢得无怨无悔,男人之美,在于撒谎撒得白日见鬼)没有错,
原函数为unsigned char *ptr,是指针,4字节,在VB中对应long型
------解决方案--------------------
wxf0204(网泥www.xmlenz.cn,QQ:21956798)
楼上的老兄,
publisc function cal_crc(byval s as integer, buval ptr as long, byval len1 as long ) as inreger
这个地方定义有问题吧,ptr应该是string类型的吧
另外 ptr=ptr+2 这个地方不能这样吧
——————————————————————————
char temp[8192];
int len=0;
unsigned short crc=0;
crc = cal_crc(0,temp,len);
code unsigned int crc16_table[256] = {
0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50a5, 0x60c6, 0x70e7,
。。。。。。。。。。。。。。。。。。。。。。。。。。。。。
0x6e17, 0x7e36, 0x4e55, 0x5e74, 0x2e93, 0x3eb2, 0x0ed1, 0x1ef0};
static unsigned short cal_crc(unsigned short s, unsigned char *ptr,
unsigned long len)
{
unsigned short crc;
unsigned char da;
crc = s;
while(len--!=0)
{
da = (unsigned char) (crc > > 8);
crc < <= 8;
crc ^= crc_ta[da^*ptr];
ptr++;
}
return (crc);
}
怎么把这个过程翻译为VB的啊?
------解决方案--------------------
不懂,路过!
------解决方案--------------------
什么语言啊,好像是C之类的东东。正打算学习。。
------解决方案--------------------
网上有现成crc16的vb代码的,你可以搜索一下,我以前下载过
------解决方案--------------------
前面一段是数组定义,比较简单,不翻译了,后面大概如下:
static unsigned short cal_crc(unsigned short s, unsigned char *ptr,
unsigned long len)
{
unsigned short crc;
unsigned char da;
crc = s;
while(len--!=0)
{
da = (unsigned char) (crc > > 8);
crc < <= 8;
crc ^= crc_ta[da^*ptr];
ptr++;
}
return (crc);
}
大概翻译如下(应该有错误,只是直接翻译的,没有经过DEBUG)
Private Declare Sub CopyMemory Lib "kernel32 " Alias "RtlMoveMemory " (pDest As Any, pSrc As Any, ByVal ByteLen As Long)
publisc function cal_crc(byval s as integer, buval ptr as long, byval len1 as long ) as inreger
dim crc as integer
dim da as string *1
dim tmp as string
crc=s
do while len1 <> 0
len1=len1-1
da=cint(crc/256)
crc=crc*256
copymemory tmp, ptr,8
crc= crc xor (da xor tmp)
ptr=ptr+2
loop
end function
------解决方案--------------------
计算 CRC 的模块直接下一个,用不着自己翻译,编程要学会“偷懒”
------解决方案--------------------
TO:wxf0204(网泥www.xmlenz.cn,QQ:21956798)
WallesCai(女人之美,在于蠢得无怨无悔,男人之美,在于撒谎撒得白日见鬼)没有错,
原函数为unsigned char *ptr,是指针,4字节,在VB中对应long型
------解决方案--------------------
wxf0204(网泥www.xmlenz.cn,QQ:21956798)
楼上的老兄,
publisc function cal_crc(byval s as integer, buval ptr as long, byval len1 as long ) as inreger
这个地方定义有问题吧,ptr应该是string类型的吧
另外 ptr=ptr+2 这个地方不能这样吧
——————————————————————————