转换为vb.net 2003 [英] Converting to vb.net 2003

查看:66
本文介绍了转换为vb.net 2003的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都可以就如何将以下程序转换为
到vb 2003给我一些想法吗?我想jsut拿这个代码并在

vb中实现它。

def.h


/ *全局类型定义* /

typedef unsigned char byte; //''byte''是一个8位

无符号值

typedef unsigned int word; //''word''是16位

无符号值

/ *全局结构定义* /

struct byte_low_hi {

byte low_byte;

byte high_byte;

};


/ *全球联盟定义* /

union word_byte {

word word16;

struct byte_low_hi byte8;

};

//代码常量

#define BMS''*''//这个

代表二进制消息的起始字节,值0x2A

#定义PASSWD 0x2D1C //这表示

工厂密码,值11548d

#define POLY 0x8005 //在CRC中使用的多项式

算法

var.c


//全局联合变量:

union word_byte crc_value; // system crc value

union word_byte adc_value; //读取的adc值



union word_byte location_value; //表的地址

发送ADC值

//全局数组变量

byte pmsg [25]; // crc buffer


//全局变量

word tsize;

Digital Indicator.c

void table_upload_req(void){

byte Len = 0x08;

byte Cmd = 0x09;

adc_value.word16 = 0x0000 ; //读取ADC值并将

存入存储器中

location_value.word16 = 0x0000;

crc_value.word16 = 0;


byte msg_size = Len-2;


pmsg [0] = Char(Len);

pmsg [1] = Char(Cmd);


for(int i = 0; i< tsize; tsize ++){


//单表上传请求包

location_value.word16 ++;

adc_value.word16 = ADC_AVE [i];


pmsg [2] = Char(adc_value。 word16.high_byte);

pmsg [3] = Char(adc_value.word16.low_byte);

pmsg [4] = Char(location_value.word16.high_byte);

pmsg [5] = Char(location_value.word16.low_byte);


crc_value.word16 = Make_Bitwise_CRC16(word msg_size);


com1.Output = BMS +

pmsg [0] +

pmsg [1] +

pmsg [2] +

pmsg [3] +

pmsg [4] +

pmsg [5] +

Char(crc_value .word16.high_byte)+

Char(crc_value.word16.low_byte);

}

}

static private int Make_Bitwise_CRC16(word msg_size){

word i,j,msg;


for(i = 0;我< msg_size; i ++){

msg =(pmsg [i]<< 8);


for(j = 0; j< 8; j ++){

if(((msg ^ crc_value.word16)> 15)0)

crc =(crc_value.word16<< 1)^ POLY;

else

crc_value.word16<< = 1;

msg<< = 1;

}

}

返回(crc_value.word16 ^ 0);

}

解决方案

cm,


对于某些人来说,它被视为一种改进,你现在可以使用未签名的

值在VB.Net中,因为在2002/2003版本中这是不可能的。


Cor


" cmdolcet69" < co ************ @ hotmail.comschreef在bericht

新闻:11 ****************** **** @ o80g2000hse.googlegr oups.com ...


任何人都可以给我一些关于如何转换以下程序的建议

到2003年的vb?我想jsut拿这个代码并在

vb中实现。


def.h


/ *全局类型定义* /

typedef unsigned char byte; //''byte''是一个8位

无符号值

typedef unsigned int word; //''word''是16位

无符号值


/ *全局结构定义* /

struct byte_low_hi {

byte low_byte;

byte high_byte;

};


/ * Global Union定义* /

联合word_byte {

word word16;

struct byte_low_hi byte8;

};


//代码常量

#define BMS''*''//这个

代表二进制消息的起始字节,值0x2A

#define PASSWD 0x2D1C //这代表

工厂密码,值11548d

#define POLY 0x8005 //使用的多项式
CRC算法中的



var.c


//全球联盟变量:

union word_byte crc_value; // system crc value

union word_byte adc_value; //读取的adc值



union word_byte location_value; //表的地址

发送ADC值

//全局数组变量

byte pmsg [25]; // crc buffer


//全局变量

word tsize;


Digital Indicator.c

void table_upload_req(void){

byte Len = 0x08;

byte Cmd = 0x09;

adc_value .word16 = 0x0000; //读取ADC值并将

存入存储器中

location_value.word16 = 0x0000;

crc_value.word16 = 0;


byte msg_size = Len-2;


pmsg [0] = Char(Len);

pmsg [1] = Char(Cmd);


for(int i = 0; i< tsize; tsize ++){


//单表上传请求包

location_value.word16 ++;

adc_value.word16 = ADC_AVE [i];


pmsg [2] = Char(adc_value。 word16.high_byte);

pmsg [3] = Char(adc_value.word16.low_byte);

pmsg [4] = Char(location_value.word16.high_byte);

pmsg [5] = Char(location_value.word16.low_byte);


crc_value.word16 = Make_Bitwise_CRC16(word msg_size);


com1.Output = BMS +

pmsg [0] +

pmsg [1] +

pmsg [2] +

pmsg [3] +

pmsg [4] +

pmsg [5] +

Char( crc_value.word16.high_byte)+

Char(crc_value.word16.low_byte);

}

}


static private int Make_Bitwise_CRC16(word msg_size){

word i,j,msg;


for(i = 0;我< msg_size; i ++){

msg =(pmsg [i]<< 8);


for(j = 0; j< 8; j ++){

if(((msg ^ crc_value.word16)> 15)0)

crc =(crc_value.word16<< 1)^ POLY;

else

crc_value.word16<< = 1;

msg<< = 1;

}

}

return(crc_value.word16 ^ 0);

}


9月9日上午8:01,Cor Ligthert [MVP]" < notmyfirstn ... @ planet.nl>

写道:


cm,


对于某些人来说,它被视为一种改进,你现在可以在VB.Net中使用未签名的

值,因为在2002/2003版本中这是不可能的。


Cor


" cmdolcet69" < colin_dolce ... @ hotmail.comschreef in berichtnews:11 ********************** @ o80g2000hse.g ooglegroups.com ...


任何人都可以给我一些关于如何将以下程序转换为
到vb 2003的想法吗?我想jsut拿这个代码并在

vb中实现它。


def.h


/ *全局类型定义* /

typedef unsigned char byte; //''byte''是一个8位

无符号值

typedef unsigned int word; //''word''是16位

无符号值


/ *全局结构定义* /

struct byte_low_hi {

byte low_byte;

byte high_byte;

};


/ * Global Union Definitions * /

union word_byte {

word word16;

struct byte_low_hi byte8;

};


//代码常量

#define BMS''*''//这个

代表二进制消息的起始字节,值0x2A

#define PASSWD 0x2D1C //这代表

工厂密码,值11548d

#定义POLY 0x8005 //在CRC算法中使用的多项式



var.c


//全球联盟变量:

union word_byte crc_value; // system crc value

union word_byte adc_value; //读取的adc值



union word_byte location_value; //表的地址

发送ADC值


//全局数组变量

byte pmsg [25]; // crc buffer


//全局变量

word tsize;


Digital Indicator.c


void table_upload_req(void){

字节Len = 0x08;

字节Cmd = 0x09;

adc_value.word16 = 0x0000; //读取ADC值并将

存入存储器中

location_value.word16 = 0x0000;

crc_value.word16 = 0;


byte msg_size = Len-2;


pmsg [0] = Char(Len);

pmsg [1] = Char(Cmd);


for(int i = 0; i< tsize; tsize ++){


//单表上传请求包

location_value.word16 ++;

adc_value.word16 = ADC_AVE [i];


pmsg [2] = Char(adc_value.word16.high_byte);

pmsg [3] = Char(adc_value) .word16.low_byte);

pmsg [4] = Char(location_value.word16.high_byte);

pmsg [5] = Char(location_value.word16.low_byte);


crc_value.word16 = Make_Bitwise_CRC16(word msg_size);


com1.Output = BMS +

pmsg [0] +

pmsg [1 ] +

pmsg [2] +

pmsg [3] +

pmsg [4] +

pmsg [5] +

Char(crc_value.word16.high_byte)+

Char(crc_value.word16.low_byte);

}

}


static private int Make_Bitwise_CRC16(word msg_size){

word i,j,msg;


for(i = 0; i< msg_size; i ++){

msg =(pmsg [i ]<< 8);


for(j = 0; j< 8; j ++){

if((msg ^ crc_value。 word16)> 15)0)

crc =(crc_value.word16<< 1)^ POLY;

else

crc_value。 word16<< = 1;

msg<< = 1;

}

}

return(crc_value.word16 ^ 0);

} - 隐藏引用的文字 -



- 显示引用的文字 -



所以你说我可以把它转换成vb?


(通过C ++到VB转换器)

请注意,从C ++自动转换只是第一步。下面生成的代码

几乎肯定需要进一步调整:


Public Class GlobalMembers

''var.c

''全球联盟变量:

公共共享crc_value as word_byte''system crc value

公共共享adc_value as word_byte''adc value从表中读取

公共共享location_value作为word_byte''发送ADC的表的地址




''全局数组变量

公共共享pmsg As Byte()=新字节(24){}''crc缓冲区


''全局变量

公共共享tsize作为UInteger


''数字指示器。


公共共享子table_upload_req()

Dim Len As Byte =& H08

Dim Cmd As Byte =& H09

adc_value.word16 =& H0000''读取ADC值并存入存储var

location_value.word16 =& H0000

crc_value.wor d16 = 0


Dim msg_size As Byte = Len-2


pmsg(0)= ChrW(Len)

pmsg(1)= ChrW(Cmd)


Dim i As Integer = 0

Do while< tsize


''单表上传请求包

location_value.word16 + = 1

adc_value.word16 = ADC_AVE(i)


pmsg(2)= CChar(adc_value.word16.high_byte)

pmsg(3)= CChar(adc_value.word16.low_byte)

pmsg(4)= CChar(location_value.word16.high_byte)

pmsg(5)= CChar(location_value.word16.low_byte)

crc_value.word16 = Make_Bitwise_CRC16(UInteger msg_size)


com1.Output = DefineConstants.BMS + pmsg(0)+ pmsg(1)+ pmsg(2)+ pmsg(3)

+ pmsg( 4)+ pmsg(5)+ CChar(crc_value.word16.high_byte)+

CChar(crc_value.word16.low_byte)

tsize + = 1

循环

结束子


朋友分享的朋友功能Make_Bitwise_CRC16(ByVal msg_size As

UInteger)作为整数

Dim i As UInteger

Dim j作为UInteger

Dim msg作为UInteger


对于i = 0到msg_size - 1

msg =(pmsg(i)<< 8)


对于j = 0到7

如果((msg Xor crc_value.word16)> 15)0那么

crc =(crc_value.word16<< 1)Xor DefineConstants.POLY

Else

crc_value.word16<< = 1

结束如果

msg<< = 1

下一个j

下一个我

返回(crc_value。 word16 Xor 0)

结束功能

结束课程

''def.h


' '全局类型定义


''全球结构定义

公共类byte_low_hi

公共low_byte As Byte

Public high_byte As Byte

End Class


''全球联盟定义

''C ++ to VB CONVERTER TODO TASK: VB不支持工会。

''ORIGINAL LINE:union word_byte

公共结构word_byte

公共字16作为UInteger

公共byte8 as byte_low_hi

结束结构


''代码常量
#Const BMS = True''这表示二进制消息的起始字节,值0x2A

#Const PASSWD = True''这表示工厂密码,值11548d

#Const POLY = True''CRC算法中使用的多项式


Friend NotInheritable Class DefineConstants

Public Const BMS As Char = " *" c

Public Const PASSWD As Integer =& H2D1C

Public Const POLY As Integer =& H8005

End Class

-

David Anton
http://www.tangiblesoftwaresolutions.com

VB,C#,C ++和Java之间的转换

即时C#

即时VB

即时C ++

C ++到C#转换器

C ++到VB转换器

C ++到Java转换器
" cmdolcet69"写道:


任何人都可以给我一些关于如何转换以下程序的想法

到vb 2003?我想jsut拿这个代码并在

vb中实现。


def.h


/ *全局类型定义* /

typedef unsigned char byte; //''byte''是一个8位

无符号值

typedef unsigned int word; //''word''是16位

无符号值


/ *全局结构定义* /

struct byte_low_hi {

byte low_byte;

byte high_byte;

};


/ * Global Union定义* /

联合word_byte {

word word16;

struct byte_low_hi byte8;

};


//代码常量

#define BMS''*''//这个

代表二进制消息的起始字节,值0x2A

#define PASSWD 0x2D1C //这代表

工厂密码,值11548d

#define POLY 0x8005 //使用的多项式
CRC算法中的



var.c


//全球联盟变量:

union word_byte crc_value; // system crc value

union word_byte adc_value; //读取的adc值



union word_byte location_value; //表的地址

发送ADC值

//全局数组变量

byte pmsg [25]; // crc buffer


//全局变量

word tsize;


Digital Indicator.c

void table_upload_req(void){

byte Len = 0x08;

byte Cmd = 0x09;

adc_value .word16 = 0x0000; //读取ADC值并将

存入存储器中

location_value.word16 = 0x0000;

crc_value.word16 = 0;


byte msg_size = Len-2;


pmsg [0] = Char(Len);

pmsg [1] = Char(Cmd);


for(int i = 0; i< tsize; tsize ++){


//单表上传请求包

location_value.word16 ++;

adc_value.word16 = ADC_AVE [i];


pmsg [2] = Char(adc_value。 word16.high_byte);

pmsg [3] = Char(adc_value.word16.low_byte);

pmsg [4] = Char(location_value.word16.high_byte);

pmsg [5] = Char(location_value.word16.low_byte);


crc_value.word16 = Make_Bitwise_CRC16(word msg_size);


com1.Output = BMS +

pmsg [0] +

pmsg [1] +

pmsg [2] +

pmsg [3] +

pmsg [4] +

pmsg [5] +

Char(crc_value.word16.high_byte)+

Char(crc_value.word16.low_byte);

}

}


static private int Make_Bitwise_CRC16(word msg_size){

word i,j,msg;


for(i = 0;我< msg_size; i ++){

msg =(pmsg [i]<< 8);


for(j = 0; j< 8; j ++){

if(((msg ^ crc_value.word16)> 15)0)

crc =(crc_value.word16<< 1)^ POLY;

else

crc_value.word16<< = 1;

msg<< = 1;

}

}

return(crc_value.word16 ^ 0);

}


Can anyone give me some ideas on how to convert the following program
to vb 2003? I would like to jsut take this code and implement it in
vb.
def.h

/* Global Type Definitions */
typedef unsigned char byte; // ''byte'' is an 8-bit
unsigned value
typedef unsigned int word; // ''word'' is a 16-bit
unsigned value
/* Global Structure Definitions */
struct byte_low_hi {
byte low_byte;
byte high_byte;
};

/* Global Union Definitions */
union word_byte {
word word16;
struct byte_low_hi byte8;
};
//Code Constants
#define BMS ''*'' // this
represents the binary message start byte, value 0x2A
#define PASSWD 0x2D1C // this represents the
factory pass code, value 11548d
#define POLY 0x8005 // the polynomial used
in the CRC algorithm
var.c

// Global Union Variables:
union word_byte crc_value; // system crc value
union word_byte adc_value; // adc value read from
table
union word_byte location_value; // address of table to
send ADC value

// Global Array Variables
byte pmsg [25]; // crc buffer

// Global Variables
word tsize;
Digital Indicator.c

void table_upload_req(void) {
byte Len = 0x08;
byte Cmd = 0x09;
adc_value.word16 = 0x0000; // read ADC value and put
into storage var
location_value.word16 = 0x0000;
crc_value.word16 = 0;

byte msg_size = Len-2;

pmsg[0] = Char(Len);
pmsg[1] = Char(Cmd);

for(int i=0; i<tsize; tsize++) {

// single table upload request packet
location_value.word16++;
adc_value.word16 = ADC_AVE[i];

pmsg[2] = Char(adc_value.word16.high_byte);
pmsg[3] = Char(adc_value.word16.low_byte);
pmsg[4] = Char(location_value.word16.high_byte);
pmsg[5] = Char(location_value.word16.low_byte);

crc_value.word16 = Make_Bitwise_CRC16(word msg_size);

com1.Output = BMS +
pmsg[0] +
pmsg[1] +
pmsg[2] +
pmsg[3] +
pmsg[4] +
pmsg[5] +
Char(crc_value.word16.high_byte) +
Char(crc_value.word16.low_byte);
}
}
static private int Make_Bitwise_CRC16(word msg_size) {
word i, j, msg;

for(i = 0; i < msg_size; i ++) {
msg = (pmsg[i] << 8) ;

for(j = 0; j < 8; j++) {
if ( ((msg ^ crc_value.word16) >15) 0)
crc = (crc_value.word16 << 1) ^ POLY;
else
crc_value.word16 <<= 1;
msg <<= 1;
}
}
return(crc_value.word16 ^ 0);
}

解决方案

cm,

For some people it is seen as an improvement that you can now use unsigned
values in VB.Net because that was impossible in version 2002/2003.

Cor

"cmdolcet69" <co************@hotmail.comschreef in bericht
news:11**********************@o80g2000hse.googlegr oups.com...

Can anyone give me some ideas on how to convert the following program
to vb 2003? I would like to jsut take this code and implement it in
vb.
def.h

/* Global Type Definitions */
typedef unsigned char byte; // ''byte'' is an 8-bit
unsigned value
typedef unsigned int word; // ''word'' is a 16-bit
unsigned value
/* Global Structure Definitions */
struct byte_low_hi {
byte low_byte;
byte high_byte;
};

/* Global Union Definitions */
union word_byte {
word word16;
struct byte_low_hi byte8;
};
//Code Constants
#define BMS ''*'' // this
represents the binary message start byte, value 0x2A
#define PASSWD 0x2D1C // this represents the
factory pass code, value 11548d
#define POLY 0x8005 // the polynomial used
in the CRC algorithm
var.c

// Global Union Variables:
union word_byte crc_value; // system crc value
union word_byte adc_value; // adc value read from
table
union word_byte location_value; // address of table to
send ADC value

// Global Array Variables
byte pmsg [25]; // crc buffer

// Global Variables
word tsize;
Digital Indicator.c

void table_upload_req(void) {
byte Len = 0x08;
byte Cmd = 0x09;
adc_value.word16 = 0x0000; // read ADC value and put
into storage var
location_value.word16 = 0x0000;
crc_value.word16 = 0;

byte msg_size = Len-2;

pmsg[0] = Char(Len);
pmsg[1] = Char(Cmd);

for(int i=0; i<tsize; tsize++) {

// single table upload request packet
location_value.word16++;
adc_value.word16 = ADC_AVE[i];

pmsg[2] = Char(adc_value.word16.high_byte);
pmsg[3] = Char(adc_value.word16.low_byte);
pmsg[4] = Char(location_value.word16.high_byte);
pmsg[5] = Char(location_value.word16.low_byte);

crc_value.word16 = Make_Bitwise_CRC16(word msg_size);

com1.Output = BMS +
pmsg[0] +
pmsg[1] +
pmsg[2] +
pmsg[3] +
pmsg[4] +
pmsg[5] +
Char(crc_value.word16.high_byte) +
Char(crc_value.word16.low_byte);
}
}
static private int Make_Bitwise_CRC16(word msg_size) {
word i, j, msg;

for(i = 0; i < msg_size; i ++) {
msg = (pmsg[i] << 8) ;

for(j = 0; j < 8; j++) {
if ( ((msg ^ crc_value.word16) >15) 0)
crc = (crc_value.word16 << 1) ^ POLY;
else
crc_value.word16 <<= 1;
msg <<= 1;
}
}
return(crc_value.word16 ^ 0);
}


On Sep 9, 8:01 am, "Cor Ligthert[MVP]" <notmyfirstn...@planet.nl>
wrote:

cm,

For some people it is seen as an improvement that you can now use unsigned
values in VB.Net because that was impossible in version 2002/2003.

Cor

"cmdolcet69" <colin_dolce...@hotmail.comschreef in berichtnews:11**********************@o80g2000hse.g ooglegroups.com...

Can anyone give me some ideas on how to convert the following program
to vb 2003? I would like to jsut take this code and implement it in
vb.

def.h

/* Global Type Definitions */
typedef unsigned char byte; // ''byte'' is an 8-bit
unsigned value
typedef unsigned int word; // ''word'' is a 16-bit
unsigned value

/* Global Structure Definitions */
struct byte_low_hi {
byte low_byte;
byte high_byte;
};

/* Global Union Definitions */
union word_byte {
word word16;
struct byte_low_hi byte8;
};

//Code Constants
#define BMS ''*'' // this
represents the binary message start byte, value 0x2A
#define PASSWD 0x2D1C // this represents the
factory pass code, value 11548d
#define POLY 0x8005 // the polynomial used
in the CRC algorithm

var.c

// Global Union Variables:
union word_byte crc_value; // system crc value
union word_byte adc_value; // adc value read from
table
union word_byte location_value; // address of table to
send ADC value

// Global Array Variables
byte pmsg [25]; // crc buffer

// Global Variables
word tsize;

Digital Indicator.c

void table_upload_req(void) {
byte Len = 0x08;
byte Cmd = 0x09;
adc_value.word16 = 0x0000; // read ADC value and put
into storage var
location_value.word16 = 0x0000;
crc_value.word16 = 0;

byte msg_size = Len-2;

pmsg[0] = Char(Len);
pmsg[1] = Char(Cmd);

for(int i=0; i<tsize; tsize++) {

// single table upload request packet
location_value.word16++;
adc_value.word16 = ADC_AVE[i];

pmsg[2] = Char(adc_value.word16.high_byte);
pmsg[3] = Char(adc_value.word16.low_byte);
pmsg[4] = Char(location_value.word16.high_byte);
pmsg[5] = Char(location_value.word16.low_byte);

crc_value.word16 = Make_Bitwise_CRC16(word msg_size);

com1.Output = BMS +
pmsg[0] +
pmsg[1] +
pmsg[2] +
pmsg[3] +
pmsg[4] +
pmsg[5] +
Char(crc_value.word16.high_byte) +
Char(crc_value.word16.low_byte);
}
}

static private int Make_Bitwise_CRC16(word msg_size) {
word i, j, msg;

for(i = 0; i < msg_size; i ++) {
msg = (pmsg[i] << 8) ;

for(j = 0; j < 8; j++) {
if ( ((msg ^ crc_value.word16) >15) 0)
crc = (crc_value.word16 << 1) ^ POLY;
else
crc_value.word16 <<= 1;
msg <<= 1;
}
}
return(crc_value.word16 ^ 0);
}- Hide quoted text -


- Show quoted text -

So your saying that i can;t convert this into vb?


(via C++ to VB Converter)
Note that automated conversion from C++ is just a first step. The code
produced below will almost certainly need further adjustments:

Public Class GlobalMembers
''var.c

'' Global Union Variables:
Public Shared crc_value As word_byte '' system crc value
Public Shared adc_value As word_byte '' adc value read from table
Public Shared location_value As word_byte '' address of table to send ADC
value

'' Global Array Variables
Public Shared pmsg As Byte() = New Byte(24){} '' crc buffer

'' Global Variables
Public Shared tsize As UInteger

''Digital Indicator.c

Public Shared Sub table_upload_req()
Dim Len As Byte = &H08
Dim Cmd As Byte = &H09
adc_value.word16 = &H0000 '' read ADC value and put into storage var
location_value.word16 = &H0000
crc_value.word16 = 0

Dim msg_size As Byte = Len-2

pmsg(0) = ChrW(Len)
pmsg(1) = ChrW(Cmd)

Dim i As Integer =0
Do While i<tsize

'' single table upload request packet
location_value.word16 += 1
adc_value.word16 = ADC_AVE(i)

pmsg(2) = CChar(adc_value.word16.high_byte)
pmsg(3) = CChar(adc_value.word16.low_byte)
pmsg(4) = CChar(location_value.word16.high_byte)
pmsg(5) = CChar(location_value.word16.low_byte)

crc_value.word16 = Make_Bitwise_CRC16(UInteger msg_size)

com1.Output = DefineConstants.BMS + pmsg(0) + pmsg(1) + pmsg(2) + pmsg(3)
+ pmsg(4) + pmsg(5) + CChar(crc_value.word16.high_byte) +
CChar(crc_value.word16.low_byte)
tsize += 1
Loop
End Sub

Friend Shared Friend Function Make_Bitwise_CRC16(ByVal msg_size As
UInteger) As Integer
Dim i As UInteger
Dim j As UInteger
Dim msg As UInteger

For i = 0 To msg_size - 1
msg = (pmsg(i) << 8)

For j = 0 To 7
If ((msg Xor crc_value.word16) >15) 0 Then
crc = (crc_value.word16 << 1) Xor DefineConstants.POLY
Else
crc_value.word16 <<= 1
End If
msg <<= 1
Next j
Next i
Return(crc_value.word16 Xor 0)
End Function
End Class
''def.h

'' Global Type Definitions

'' Global Structure Definitions
Public Class byte_low_hi
Public low_byte As Byte
Public high_byte As Byte
End Class

'' Global Union Definitions
''C++ to VB CONVERTER TODO TASK: Unions are not supported in VB.
''ORIGINAL LINE: union word_byte
Public Structure word_byte
Public word16 As UInteger
Public byte8 As byte_low_hi
End Structure

''Code Constants
#Const BMS = True '' this represents the binary message start byte, value 0x2A
#Const PASSWD = True '' this represents the factory pass code, value 11548d
#Const POLY = True '' the polynomial used in the CRC algorithm

Friend NotInheritable Class DefineConstants
Public Const BMS As Char = "*"c
Public Const PASSWD As Integer = &H2D1C
Public Const POLY As Integer = &H8005
End Class
--
David Anton
http://www.tangiblesoftwaresolutions.com
Convert between VB, C#, C++, and Java
Instant C#
Instant VB
Instant C++
C++ to C# Converter
C++ to VB Converter
C++ to Java Converter
"cmdolcet69" wrote:

Can anyone give me some ideas on how to convert the following program
to vb 2003? I would like to jsut take this code and implement it in
vb.
def.h

/* Global Type Definitions */
typedef unsigned char byte; // ''byte'' is an 8-bit
unsigned value
typedef unsigned int word; // ''word'' is a 16-bit
unsigned value
/* Global Structure Definitions */
struct byte_low_hi {
byte low_byte;
byte high_byte;
};

/* Global Union Definitions */
union word_byte {
word word16;
struct byte_low_hi byte8;
};
//Code Constants
#define BMS ''*'' // this
represents the binary message start byte, value 0x2A
#define PASSWD 0x2D1C // this represents the
factory pass code, value 11548d
#define POLY 0x8005 // the polynomial used
in the CRC algorithm
var.c

// Global Union Variables:
union word_byte crc_value; // system crc value
union word_byte adc_value; // adc value read from
table
union word_byte location_value; // address of table to
send ADC value

// Global Array Variables
byte pmsg [25]; // crc buffer

// Global Variables
word tsize;
Digital Indicator.c

void table_upload_req(void) {
byte Len = 0x08;
byte Cmd = 0x09;
adc_value.word16 = 0x0000; // read ADC value and put
into storage var
location_value.word16 = 0x0000;
crc_value.word16 = 0;

byte msg_size = Len-2;

pmsg[0] = Char(Len);
pmsg[1] = Char(Cmd);

for(int i=0; i<tsize; tsize++) {

// single table upload request packet
location_value.word16++;
adc_value.word16 = ADC_AVE[i];

pmsg[2] = Char(adc_value.word16.high_byte);
pmsg[3] = Char(adc_value.word16.low_byte);
pmsg[4] = Char(location_value.word16.high_byte);
pmsg[5] = Char(location_value.word16.low_byte);

crc_value.word16 = Make_Bitwise_CRC16(word msg_size);

com1.Output = BMS +
pmsg[0] +
pmsg[1] +
pmsg[2] +
pmsg[3] +
pmsg[4] +
pmsg[5] +
Char(crc_value.word16.high_byte) +
Char(crc_value.word16.low_byte);
}
}
static private int Make_Bitwise_CRC16(word msg_size) {
word i, j, msg;

for(i = 0; i < msg_size; i ++) {
msg = (pmsg[i] << 8) ;

for(j = 0; j < 8; j++) {
if ( ((msg ^ crc_value.word16) >15) 0)
crc = (crc_value.word16 << 1) ^ POLY;
else
crc_value.word16 <<= 1;
msg <<= 1;
}
}
return(crc_value.word16 ^ 0);
}


这篇关于转换为vb.net 2003的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆