473,406 Members | 2,894 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Converting to vb.net 2003

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);
}

Sep 9 '07 #1
12 2098
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);
}
Sep 9 '07 #2
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?

Sep 9 '07 #3
(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);
}

Sep 9 '07 #4
On Sep 9, 11:12 am, David Anton <DavidAn...@discussions.microsoft.com>
wrote:
(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 Antonhttp://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);
}- Hide quoted text -

- Show quoted text -
How do i decalre UInteger (unsinged integers) in vb 2003

Sep 9 '07 #5
System.UInt32
--
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:
On Sep 9, 11:12 am, David Anton <DavidAn...@discussions.microsoft.com>
wrote:
(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 Antonhttp://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);
}- Hide quoted text -
- Show quoted text -

How do i decalre UInteger (unsinged integers) in vb 2003

Sep 9 '07 #6
On Sep 9, 12:32 pm, David Anton <DavidAn...@discussions.microsoft.com>
wrote:
System.UInt32
--
David Antonhttp://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:
On Sep 9, 11:12 am, David Anton <DavidAn...@discussions.microsoft.com>
wrote:
(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 Antonhttp://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);
}- Hide quoted text -
- Show quoted text -
How do i decalre UInteger (unsinged integers) in vb 2003- Hide quoted text -

- Show quoted text -
David can you explaine why when i add in the following it says "
UInteger is not defined"

Public Structure word_byte
Public word16 As UInteger
Public byte8 As byte_low_hi
End Structure
When i add Imports System.UInt32 and change it to Uint16 I get the
error on

Public Structure word_byte
Public word16 As UInt16
Public byte8 As byte_low_hi
End Structure

adc_value.word16 = &H0 ' read ADC value and put into storage var
location_value.word16 = &H0
crc_value.word16 = 0
The location_value.word16 = &H0 gives an error "Value of type integer
cannot be converted to System.Uint16

Sep 9 '07 #7
The VB type aliases UInteger, ULong, and UShort are only available in VB 2005
and beyond.
For the second problem, just use a cast.
--
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:
On Sep 9, 12:32 pm, David Anton <DavidAn...@discussions.microsoft.com>
wrote:
System.UInt32
--
David Antonhttp://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:
On Sep 9, 11:12 am, David Anton <DavidAn...@discussions.microsoft.com>
wrote:
(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 Antonhttp://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);
}- Hide quoted text -
- Show quoted text -
How do i decalre UInteger (unsinged integers) in vb 2003- Hide quoted text -
- Show quoted text -

David can you explaine why when i add in the following it says "
UInteger is not defined"

Public Structure word_byte
Public word16 As UInteger
Public byte8 As byte_low_hi
End Structure
When i add Imports System.UInt32 and change it to Uint16 I get the
error on

Public Structure word_byte
Public word16 As UInt16
Public byte8 As byte_low_hi
End Structure

adc_value.word16 = &H0 ' read ADC value and put into storage var
location_value.word16 = &H0
crc_value.word16 = 0
The location_value.word16 = &H0 gives an error "Value of type integer
cannot be converted to System.Uint16

Sep 9 '07 #8
On Sep 9, 3:40 pm, David Anton <DavidAn...@discussions.microsoft.com>
wrote:
The VB type aliases UInteger, ULong, and UShort are only available in VB 2005
and beyond.
For the second problem, just use a cast.
--
David Antonhttp://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:
On Sep 9, 12:32 pm, David Anton <DavidAn...@discussions.microsoft.com>
wrote:
System.UInt32
--
David Antonhttp://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:
On Sep 9, 11:12 am, David Anton <DavidAn...@discussions.microsoft.com>
wrote:
(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 Antonhttp://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);
}- Hide quoted text -
- Show quoted text -
How do i decalre UInteger (unsinged integers) in vb 2003- Hide quoted text -
- Show quoted text -
David can you explaine why when i add in the following it says "
UInteger is not defined"
Public Structure word_byte
Public word16 As UInteger
Public byte8 As byte_low_hi
End Structure
When i add Imports System.UInt32 and change it to Uint16 I get the
error on
Public Structure word_byte
Public word16 As UInt16
Public byte8 As byte_low_hi
End Structure
adc_value.word16 = &H0 ' read ADC value and put into storage var
location_value.word16 = &H0
crc_value.word16 = 0
The location_value.word16 = &H0 gives an error "Value of type integer
cannot be converted to System.Uint16- Hide quoted text -

- Show quoted text -
So for the first issue would i just set it to Integer?

Sep 9 '07 #9
Use System.UInt32 instead of UInteger for VB 2003.
--
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:
On Sep 9, 3:40 pm, David Anton <DavidAn...@discussions.microsoft.com>
wrote:
The VB type aliases UInteger, ULong, and UShort are only available in VB 2005
and beyond.
For the second problem, just use a cast.
--
David Antonhttp://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:
On Sep 9, 12:32 pm, David Anton <DavidAn...@discussions.microsoft.com>
wrote:
System.UInt32
--
David Antonhttp://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:
On Sep 9, 11:12 am, David Anton <DavidAn...@discussions.microsoft.com>
wrote:
(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 Antonhttp://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);
}- Hide quoted text -
- Show quoted text -
How do i decalre UInteger (unsinged integers) in vb 2003- Hide quoted text -
- Show quoted text -
David can you explaine why when i add in the following it says "
UInteger is not defined"
Public Structure word_byte
Public word16 As UInteger
Public byte8 As byte_low_hi
End Structure
When i add Imports System.UInt32 and change it to Uint16 I get the
error on
Public Structure word_byte
Public word16 As UInt16
Public byte8 As byte_low_hi
End Structure
adc_value.word16 = &H0 ' read ADC value and put into storage var
location_value.word16 = &H0
crc_value.word16 = 0
The location_value.word16 = &H0 gives an error "Value of type integer
cannot be converted to System.Uint16- Hide quoted text -
- Show quoted text -

So for the first issue would i just set it to Integer?

Sep 9 '07 #10
On Sep 9, 3:40 pm, David Anton <DavidAn...@discussions.microsoft.com>
wrote:
The VB type aliases UInteger, ULong, and UShort are only available in VB 2005
and beyond.
For the second problem, just use a cast.
--
David Antonhttp://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:
On Sep 9, 12:32 pm, David Anton <DavidAn...@discussions.microsoft.com>
wrote:
System.UInt32
--
David Antonhttp://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:
On Sep 9, 11:12 am, David Anton <DavidAn...@discussions.microsoft.com>
wrote:
(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 Antonhttp://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);
}- Hide quoted text -
- Show quoted text -
How do i decalre UInteger (unsinged integers) in vb 2003- Hide quoted text -
- Show quoted text -
David can you explaine why when i add in the following it says "
UInteger is not defined"
Public Structure word_byte
Public word16 As UInteger
Public byte8 As byte_low_hi
End Structure
When i add Imports System.UInt32 and change it to Uint16 I get the
error on
Public Structure word_byte
Public word16 As UInt16
Public byte8 As byte_low_hi
End Structure
adc_value.word16 = &H0 ' read ADC value and put into storage var
location_value.word16 = &H0
crc_value.word16 = 0
The location_value.word16 = &H0 gives an error "Value of type integer
cannot be converted to System.Uint16- Hide quoted text -

- Show quoted text -
Sorry for that blank post...anyways How would i then represent this in
vb 2003?

Sep 9 '07 #11
On Sep 9, 4:04 pm, David Anton <DavidAn...@discussions.microsoft.com>
wrote:
Use System.UInt32 instead of UInteger for VB 2003.
--
David Antonhttp://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:
On Sep 9, 3:40 pm, David Anton <DavidAn...@discussions.microsoft.com>
wrote:
The VB type aliases UInteger, ULong, and UShort are only available inVB 2005
and beyond.
For the second problem, just use a cast.
--
David Antonhttp://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:
On Sep 9, 12:32 pm, David Anton <DavidAn...@discussions.microsoft.com>
wrote:
System.UInt32
--
David Antonhttp://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:
On Sep 9, 11:12 am, David Anton <DavidAn...@discussions.microsoft.com>
wrote:
(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 readfrom 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){} ' crcbuffer
' 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 Antonhttp://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 an8-bit
unsigned value
typedef unsigned int word; // 'word' is a16-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 crcvalue
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

...

read more »- Hide quoted text -

- Show quoted text -
How can i fix this issue?

I get the following error - "Operator '+' is not define for types
System.Int32 and Integer"

location_value.word16 += 1

Sep 9 '07 #12
It should also be noted that because unsigned numbers are non-CLS compliant,
VB 2003 does not support operations (+, -, /, *, etc.) on unsigned numbers.
C# 2003 does support unsigned numbers, but it is still non-CLS compliant. It
is a "language feature". This "langauage feature" was then extended to VB
2005, but it is still non-CLS compliant.

I personally would use VB2005.

"cmdolcet69" wrote:
On Sep 9, 4:04 pm, David Anton <DavidAn...@discussions.microsoft.com>
wrote:
Use System.UInt32 instead of UInteger for VB 2003.
--
David Antonhttp://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:
On Sep 9, 3:40 pm, David Anton <DavidAn...@discussions.microsoft.com>
wrote:
The VB type aliases UInteger, ULong, and UShort are only available in VB 2005
and beyond.
For the second problem, just use a cast.
--
David Antonhttp://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:
On Sep 9, 12:32 pm, David Anton <DavidAn...@discussions.microsoft.com>
wrote:
System.UInt32
--
David Antonhttp://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:
On Sep 9, 11:12 am, David Anton <DavidAn...@discussions.microsoft.com>
wrote:
(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 Antonhttp://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
...

read more ;- Hide quoted text -

- Show quoted text -

How can i fix this issue?

I get the following error - "Operator '+' is not define for types
System.Int32 and Integer"

location_value.word16 += 1

Sep 10 '07 #13

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Nikola | last post by:
Hi all, I have a problem converting datetime to integer (and than back to datetime). Depending whether the time is AM or PM, same date is converted to two different integer representations,...
17
by: chicha | last post by:
Hey people, I have to convert MS Access 2000 database into mysql database, the whole thing being part of this project I'm doing for one of my faculty classes. My professor somehow presumed I...
3
by: j.a. harriman | last post by:
Hi, On MSDN I know there is a JScript example (Upgrading Visual C++ Projects to Visual Studio .NET in Batch Mode) to upgrade VS6 C++ projects to .NET solutions. It converts the project files...
4
by: (Pete Cresswell) | last post by:
I've got everything in 2000 format right now, but it's now clear that all of the clients will be running 2003. Is there any advantage in converting? -- PeteCresswell
2
by: John Ortt | last post by:
Hi All, I have a database in Access 97 which works fine but our company is converting from NT4 to XP Pro and in the process changing Office 97 for Office 2003. I have tried to convert the 97...
3
by: Andy | last post by:
Hi ! I have many simple, low-tech database applications spread throughout my organization that I developed in Access 2K.. Most have ODBC for Oracle connections ( read only ) to our principal...
0
by: Rich | last post by:
(1) Is there a better place to pose the question below? (2) I am starting to convert my enterprise solution from VS 2003 (.NET v1.1.4322) to VS 2005 Professional (.NET v2.0.50727). The entire...
2
by: Christine.Misseri | last post by:
Hi all, I'm sure someone knows about this problem. I have an Access database designed in Access 2000, connected to an ORACLE 8i back end. On the ORACLE side I have stored procedures, triggers...
6
by: Dennis D. | last post by:
Having problems converting Murach's Beginning Visual Basic.net (Prince) and Microsoft Press' Programming Visual Basic.net (Balena) examples for use in VB.net 2005 Express. The VS conversion wizard...
7
by: Coleen | last post by:
Does anyone have any good detailed information on the conversion process? We are in the process of converting 2 projects from 2003 to 2005 and have some conversion errors that I can not find...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.