473,698 Members | 2,471 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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_re q(void) {
byte Len = 0x08;
byte Cmd = 0x09;
adc_value.word1 6 = 0x0000; // read ADC value and put
into storage var
location_value. word16 = 0x0000;
crc_value.word1 6 = 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.word1 6 = ADC_AVE[i];

pmsg[2] = Char(adc_value. word16.high_byt e);
pmsg[3] = Char(adc_value. word16.low_byte );
pmsg[4] = Char(location_v alue.word16.hig h_byte);
pmsg[5] = Char(location_v alue.word16.low _byte);

crc_value.word1 6 = Make_Bitwise_CR C16(word msg_size);

com1.Output = BMS +
pmsg[0] +
pmsg[1] +
pmsg[2] +
pmsg[3] +
pmsg[4] +
pmsg[5] +
Char(crc_value. word16.high_byt e) +
Char(crc_value. word16.low_byte );
}
}
static private int Make_Bitwise_CR C16(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.word1 6) >15) 0)
crc = (crc_value.word 16 << 1) ^ POLY;
else
crc_value.word1 6 <<= 1;
msg <<= 1;
}
}
return(crc_valu e.word16 ^ 0);
}

Sep 9 '07 #1
12 2114
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.comsch reef in bericht
news:11******** **************@ o80g2000hse.goo glegroups.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_re q(void) {
byte Len = 0x08;
byte Cmd = 0x09;
adc_value.word1 6 = 0x0000; // read ADC value and put
into storage var
location_value. word16 = 0x0000;
crc_value.word1 6 = 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.word1 6 = ADC_AVE[i];

pmsg[2] = Char(adc_value. word16.high_byt e);
pmsg[3] = Char(adc_value. word16.low_byte );
pmsg[4] = Char(location_v alue.word16.hig h_byte);
pmsg[5] = Char(location_v alue.word16.low _byte);

crc_value.word1 6 = Make_Bitwise_CR C16(word msg_size);

com1.Output = BMS +
pmsg[0] +
pmsg[1] +
pmsg[2] +
pmsg[3] +
pmsg[4] +
pmsg[5] +
Char(crc_value. word16.high_byt e) +
Char(crc_value. word16.low_byte );
}
}
static private int Make_Bitwise_CR C16(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.word1 6) >15) 0)
crc = (crc_value.word 16 << 1) ^ POLY;
else
crc_value.word1 6 <<= 1;
msg <<= 1;
}
}
return(crc_valu e.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.comsch reef in berichtnews:11* *************** ******@o80g2000 hse.googlegroup s.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_re q(void) {
byte Len = 0x08;
byte Cmd = 0x09;
adc_value.word1 6 = 0x0000; // read ADC value and put
into storage var
location_value. word16 = 0x0000;
crc_value.word1 6 = 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.word1 6 = ADC_AVE[i];
pmsg[2] = Char(adc_value. word16.high_byt e);
pmsg[3] = Char(adc_value. word16.low_byte );
pmsg[4] = Char(location_v alue.word16.hig h_byte);
pmsg[5] = Char(location_v alue.word16.low _byte);
crc_value.word1 6 = Make_Bitwise_CR C16(word msg_size);
com1.Output = BMS +
pmsg[0] +
pmsg[1] +
pmsg[2] +
pmsg[3] +
pmsg[4] +
pmsg[5] +
Char(crc_value. word16.high_byt e) +
Char(crc_value. word16.low_byte );
}
}
static private int Make_Bitwise_CR C16(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.word1 6) >15) 0)
crc = (crc_value.word 16 << 1) ^ POLY;
else
crc_value.word1 6 <<= 1;
msg <<= 1;
}
}
return(crc_valu e.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_re q()
Dim Len As Byte = &H08
Dim Cmd As Byte = &H09
adc_value.word1 6 = &H0000 ' read ADC value and put into storage var
location_value. word16 = &H0000
crc_value.word1 6 = 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.word1 6 = ADC_AVE(i)

pmsg(2) = CChar(adc_value .word16.high_by te)
pmsg(3) = CChar(adc_value .word16.low_byt e)
pmsg(4) = CChar(location_ value.word16.hi gh_byte)
pmsg(5) = CChar(location_ value.word16.lo w_byte)

crc_value.word1 6 = Make_Bitwise_CR C16(UInteger msg_size)

com1.Output = DefineConstants .BMS + pmsg(0) + pmsg(1) + pmsg(2) + pmsg(3)
+ pmsg(4) + pmsg(5) + CChar(crc_value .word16.high_by te) +
CChar(crc_value .word16.low_byt e)
tsize += 1
Loop
End Sub

Friend Shared Friend Function Make_Bitwise_CR C16(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.word1 6) >15) 0 Then
crc = (crc_value.word 16 << 1) Xor DefineConstants .POLY
Else
crc_value.word1 6 <<= 1
End If
msg <<= 1
Next j
Next i
Return(crc_valu e.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_re q(void) {
byte Len = 0x08;
byte Cmd = 0x09;
adc_value.word1 6 = 0x0000; // read ADC value and put
into storage var
location_value. word16 = 0x0000;
crc_value.word1 6 = 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.word1 6 = ADC_AVE[i];

pmsg[2] = Char(adc_value. word16.high_byt e);
pmsg[3] = Char(adc_value. word16.low_byte );
pmsg[4] = Char(location_v alue.word16.hig h_byte);
pmsg[5] = Char(location_v alue.word16.low _byte);

crc_value.word1 6 = Make_Bitwise_CR C16(word msg_size);

com1.Output = BMS +
pmsg[0] +
pmsg[1] +
pmsg[2] +
pmsg[3] +
pmsg[4] +
pmsg[5] +
Char(crc_value. word16.high_byt e) +
Char(crc_value. word16.low_byte );
}
}
static private int Make_Bitwise_CR C16(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.word1 6) >15) 0)
crc = (crc_value.word 16 << 1) ^ POLY;
else
crc_value.word1 6 <<= 1;
msg <<= 1;
}
}
return(crc_valu e.word16 ^ 0);
}

Sep 9 '07 #4
On Sep 9, 11:12 am, David Anton <DavidAn...@dis cussions.micros oft.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_re q()
Dim Len As Byte = &H08
Dim Cmd As Byte = &H09
adc_value.word1 6 = &H0000 ' read ADC value and put into storage var
location_value. word16 = &H0000
crc_value.word1 6 = 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.word1 6 = ADC_AVE(i)

pmsg(2) = CChar(adc_value .word16.high_by te)
pmsg(3) = CChar(adc_value .word16.low_byt e)
pmsg(4) = CChar(location_ value.word16.hi gh_byte)
pmsg(5) = CChar(location_ value.word16.lo w_byte)

crc_value.word1 6 = Make_Bitwise_CR C16(UInteger msg_size)

com1.Output = DefineConstants .BMS + pmsg(0) + pmsg(1) + pmsg(2) + pmsg(3)
+ pmsg(4) + pmsg(5) + CChar(crc_value .word16.high_by te) +
CChar(crc_value .word16.low_byt e)
tsize += 1
Loop
End Sub

Friend Shared Friend Function Make_Bitwise_CR C16(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.word1 6) >15) 0 Then
crc = (crc_value.word 16 << 1) Xor DefineConstants .POLY
Else
crc_value.word1 6 <<= 1
End If
msg <<= 1
Next j
Next i
Return(crc_valu e.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.tangiblesof twaresolutions. 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_re q(void) {
byte Len = 0x08;
byte Cmd = 0x09;
adc_value.word1 6 = 0x0000; // read ADC value and put
into storage var
location_value. word16 = 0x0000;
crc_value.word1 6 = 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.word1 6 = ADC_AVE[i];
pmsg[2] = Char(adc_value. word16.high_byt e);
pmsg[3] = Char(adc_value. word16.low_byte );
pmsg[4] = Char(location_v alue.word16.hig h_byte);
pmsg[5] = Char(location_v alue.word16.low _byte);
crc_value.word1 6 = Make_Bitwise_CR C16(word msg_size);
com1.Output = BMS +
pmsg[0] +
pmsg[1] +
pmsg[2] +
pmsg[3] +
pmsg[4] +
pmsg[5] +
Char(crc_value. word16.high_byt e) +
Char(crc_value. word16.low_byte );
}
}
static private int Make_Bitwise_CR C16(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.word1 6) >15) 0)
crc = (crc_value.word 16 << 1) ^ POLY;
else
crc_value.word1 6 <<= 1;
msg <<= 1;
}
}
return(crc_valu e.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...@dis cussions.micros oft.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_re q()
Dim Len As Byte = &H08
Dim Cmd As Byte = &H09
adc_value.word1 6 = &H0000 ' read ADC value and put into storage var
location_value. word16 = &H0000
crc_value.word1 6 = 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.word1 6 = ADC_AVE(i)

pmsg(2) = CChar(adc_value .word16.high_by te)
pmsg(3) = CChar(adc_value .word16.low_byt e)
pmsg(4) = CChar(location_ value.word16.hi gh_byte)
pmsg(5) = CChar(location_ value.word16.lo w_byte)

crc_value.word1 6 = Make_Bitwise_CR C16(UInteger msg_size)

com1.Output = DefineConstants .BMS + pmsg(0) + pmsg(1) + pmsg(2) + pmsg(3)
+ pmsg(4) + pmsg(5) + CChar(crc_value .word16.high_by te) +
CChar(crc_value .word16.low_byt e)
tsize += 1
Loop
End Sub

Friend Shared Friend Function Make_Bitwise_CR C16(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.word1 6) >15) 0 Then
crc = (crc_value.word 16 << 1) Xor DefineConstants .POLY
Else
crc_value.word1 6 <<= 1
End If
msg <<= 1
Next j
Next i
Return(crc_valu e.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.tangiblesof twaresolutions. 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_re q(void) {
byte Len = 0x08;
byte Cmd = 0x09;
adc_value.word1 6 = 0x0000; // read ADC value and put
into storage var
location_value. word16 = 0x0000;
crc_value.word1 6 = 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.word1 6 = ADC_AVE[i];
pmsg[2] = Char(adc_value. word16.high_byt e);
pmsg[3] = Char(adc_value. word16.low_byte );
pmsg[4] = Char(location_v alue.word16.hig h_byte);
pmsg[5] = Char(location_v alue.word16.low _byte);
crc_value.word1 6 = Make_Bitwise_CR C16(word msg_size);
com1.Output = BMS +
pmsg[0] +
pmsg[1] +
pmsg[2] +
pmsg[3] +
pmsg[4] +
pmsg[5] +
Char(crc_value. word16.high_byt e) +
Char(crc_value. word16.low_byte );
}
}
static private int Make_Bitwise_CR C16(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.word1 6) >15) 0)
crc = (crc_value.word 16 << 1) ^ POLY;
else
crc_value.word1 6 <<= 1;
msg <<= 1;
}
}
return(crc_valu e.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...@dis cussions.micros oft.com>
wrote:
System.UInt32
--
David Antonhttp://www.tangiblesof twaresolutions. 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...@dis cussions.micros oft.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_re q()
Dim Len As Byte = &H08
Dim Cmd As Byte = &H09
adc_value.word1 6 = &H0000 ' read ADC value and put into storage var
location_value. word16 = &H0000
crc_value.word1 6 = 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.word1 6 = ADC_AVE(i)
pmsg(2) = CChar(adc_value .word16.high_by te)
pmsg(3) = CChar(adc_value .word16.low_byt e)
pmsg(4) = CChar(location_ value.word16.hi gh_byte)
pmsg(5) = CChar(location_ value.word16.lo w_byte)
crc_value.word1 6 = Make_Bitwise_CR C16(UInteger msg_size)
com1.Output = DefineConstants .BMS + pmsg(0) + pmsg(1) + pmsg(2) + pmsg(3)
+ pmsg(4) + pmsg(5) + CChar(crc_value .word16.high_by te) +
CChar(crc_value .word16.low_byt e)
tsize += 1
Loop
End Sub
Friend Shared Friend Function Make_Bitwise_CR C16(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.word1 6) >15) 0 Then
crc = (crc_value.word 16 << 1) Xor DefineConstants .POLY
Else
crc_value.word1 6 <<= 1
End If
msg <<= 1
Next j
Next i
Return(crc_valu e.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.tangiblesof twaresolutions. 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_re q(void) {
byte Len = 0x08;
byte Cmd = 0x09;
adc_value.word1 6 = 0x0000; // read ADC value and put
into storage var
location_value. word16 = 0x0000;
crc_value.word1 6 = 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.word1 6 = ADC_AVE[i];
pmsg[2] = Char(adc_value. word16.high_byt e);
pmsg[3] = Char(adc_value. word16.low_byte );
pmsg[4] = Char(location_v alue.word16.hig h_byte);
pmsg[5] = Char(location_v alue.word16.low _byte);
crc_value.word1 6 = Make_Bitwise_CR C16(word msg_size);
com1.Output = BMS +
pmsg[0] +
pmsg[1] +
pmsg[2] +
pmsg[3] +
pmsg[4] +
pmsg[5] +
Char(crc_value. word16.high_byt e) +
Char(crc_value. word16.low_byte );
}
}
static private int Make_Bitwise_CR C16(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.word1 6) >15) 0)
crc = (crc_value.word 16 << 1) ^ POLY;
else
crc_value.word1 6 <<= 1;
msg <<= 1;
}
}
return(crc_valu e.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.word1 6 = &H0 ' read ADC value and put into storage var
location_value. word16 = &H0
crc_value.word1 6 = 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...@dis cussions.micros oft.com>
wrote:
System.UInt32
--
David Antonhttp://www.tangiblesof twaresolutions. 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...@dis cussions.micros oft.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_re q()
Dim Len As Byte = &H08
Dim Cmd As Byte = &H09
adc_value.word1 6 = &H0000 ' read ADC value and put into storage var
location_value. word16 = &H0000
crc_value.word1 6 = 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.word1 6 = ADC_AVE(i)
pmsg(2) = CChar(adc_value .word16.high_by te)
pmsg(3) = CChar(adc_value .word16.low_byt e)
pmsg(4) = CChar(location_ value.word16.hi gh_byte)
pmsg(5) = CChar(location_ value.word16.lo w_byte)
crc_value.word1 6 = Make_Bitwise_CR C16(UInteger msg_size)
com1.Output = DefineConstants .BMS + pmsg(0) + pmsg(1) + pmsg(2) + pmsg(3)
+ pmsg(4) + pmsg(5) + CChar(crc_value .word16.high_by te) +
CChar(crc_value .word16.low_byt e)
tsize += 1
Loop
End Sub
Friend Shared Friend Function Make_Bitwise_CR C16(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.word1 6) >15) 0 Then
crc = (crc_value.word 16 << 1) Xor DefineConstants .POLY
Else
crc_value.word1 6 <<= 1
End If
msg <<= 1
Next j
Next i
Return(crc_valu e.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.tangiblesof twaresolutions. 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_re q(void) {
byte Len = 0x08;
byte Cmd = 0x09;
adc_value.word1 6 = 0x0000; // read ADC value and put
into storage var
location_value. word16 = 0x0000;
crc_value.word1 6 = 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.word1 6 = ADC_AVE[i];
pmsg[2] = Char(adc_value. word16.high_byt e);
pmsg[3] = Char(adc_value. word16.low_byte );
pmsg[4] = Char(location_v alue.word16.hig h_byte);
pmsg[5] = Char(location_v alue.word16.low _byte);
crc_value.word1 6 = Make_Bitwise_CR C16(word msg_size);
com1.Output = BMS +
pmsg[0] +
pmsg[1] +
pmsg[2] +
pmsg[3] +
pmsg[4] +
pmsg[5] +
Char(crc_value. word16.high_byt e) +
Char(crc_value. word16.low_byte );
}
}
static private int Make_Bitwise_CR C16(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.word1 6) >15) 0)
crc = (crc_value.word 16 << 1) ^ POLY;
else
crc_value.word1 6 <<= 1;
msg <<= 1;
}
}
return(crc_valu e.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.word1 6 = &H0 ' read ADC value and put into storage var
location_value. word16 = &H0
crc_value.word1 6 = 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...@dis cussions.micros oft.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.tangiblesof twaresolutions. 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...@dis cussions.micros oft.com>
wrote:
System.UInt32
--
David Antonhttp://www.tangiblesof twaresolutions. 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...@dis cussions.micros oft.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_re q()
Dim Len As Byte = &H08
Dim Cmd As Byte = &H09
adc_value.word1 6 = &H0000 ' read ADC value and put into storage var
location_value. word16 = &H0000
crc_value.word1 6 = 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.word1 6 = ADC_AVE(i)
pmsg(2) = CChar(adc_value .word16.high_by te)
pmsg(3) = CChar(adc_value .word16.low_byt e)
pmsg(4) = CChar(location_ value.word16.hi gh_byte)
pmsg(5) = CChar(location_ value.word16.lo w_byte)
crc_value.word1 6 = Make_Bitwise_CR C16(UInteger msg_size)
com1.Output = DefineConstants .BMS + pmsg(0) + pmsg(1) + pmsg(2) + pmsg(3)
+ pmsg(4) + pmsg(5) + CChar(crc_value .word16.high_by te) +
CChar(crc_value .word16.low_byt e)
tsize += 1
Loop
End Sub
Friend Shared Friend Function Make_Bitwise_CR C16(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.word1 6) >15) 0 Then
crc = (crc_value.word 16 << 1) Xor DefineConstants .POLY
Else
crc_value.word1 6 <<= 1
End If
msg <<= 1
Next j
Next i
Return(crc_valu e.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.tangiblesof twaresolutions. 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_re q(void) {
byte Len = 0x08;
byte Cmd = 0x09;
adc_value.word1 6 = 0x0000; // read ADC value and put
into storage var
location_value. word16 = 0x0000;
crc_value.word1 6 = 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.word1 6 = ADC_AVE[i];
pmsg[2] = Char(adc_value. word16.high_byt e);
pmsg[3] = Char(adc_value. word16.low_byte );
pmsg[4] = Char(location_v alue.word16.hig h_byte);
pmsg[5] = Char(location_v alue.word16.low _byte);
crc_value.word1 6 = Make_Bitwise_CR C16(word msg_size);
com1.Output = BMS +
pmsg[0] +
pmsg[1] +
pmsg[2] +
pmsg[3] +
pmsg[4] +
pmsg[5] +
Char(crc_value. word16.high_byt e) +
Char(crc_value. word16.low_byte );
}
}
static private int Make_Bitwise_CR C16(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.word1 6) >15) 0)
crc = (crc_value.word 16 << 1) ^ POLY;
else
crc_value.word1 6 <<= 1;
msg <<= 1;
}
}
return(crc_valu e.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.word1 6 = &H0 ' read ADC value and put into storage var
location_value. word16 = &H0
crc_value.word1 6 = 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...@dis cussions.micros oft.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.tangiblesof twaresolutions. 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...@dis cussions.micros oft.com>
wrote:
System.UInt32
--
David Antonhttp://www.tangiblesof twaresolutions. 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...@dis cussions.micros oft.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_re q()
Dim Len As Byte = &H08
Dim Cmd As Byte = &H09
adc_value.word1 6 = &H0000 ' read ADC value and put into storage var
location_value. word16 = &H0000
crc_value.word1 6 = 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.word1 6 = ADC_AVE(i)
pmsg(2) = CChar(adc_value .word16.high_by te)
pmsg(3) = CChar(adc_value .word16.low_byt e)
pmsg(4) = CChar(location_ value.word16.hi gh_byte)
pmsg(5) = CChar(location_ value.word16.lo w_byte)
crc_value.word1 6 = Make_Bitwise_CR C16(UInteger msg_size)
com1.Output = DefineConstants .BMS + pmsg(0) + pmsg(1) + pmsg(2) + pmsg(3)
+ pmsg(4) + pmsg(5) + CChar(crc_value .word16.high_by te) +
CChar(crc_value .word16.low_byt e)
tsize += 1
Loop
End Sub
Friend Shared Friend Function Make_Bitwise_CR C16(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.word1 6) >15) 0 Then
crc = (crc_value.word 16 << 1) Xor DefineConstants .POLY
Else
crc_value.word1 6 <<= 1
End If
msg <<= 1
Next j
Next i
Return(crc_valu e.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.tangiblesof twaresolutions. 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_re q(void) {
byte Len = 0x08;
byte Cmd = 0x09;
adc_value.word1 6 = 0x0000; // read ADC value and put
into storage var
location_value. word16 = 0x0000;
crc_value.word1 6 = 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.word1 6 = ADC_AVE[i];
pmsg[2] = Char(adc_value. word16.high_byt e);
pmsg[3] = Char(adc_value. word16.low_byte );
pmsg[4] = Char(location_v alue.word16.hig h_byte);
pmsg[5] = Char(location_v alue.word16.low _byte);
crc_value.word1 6 = Make_Bitwise_CR C16(word msg_size);
com1.Output = BMS +
pmsg[0] +
pmsg[1] +
pmsg[2] +
pmsg[3] +
pmsg[4] +
pmsg[5] +
Char(crc_value. word16.high_byt e) +
Char(crc_value. word16.low_byte );
}
}
static private int Make_Bitwise_CR C16(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.word1 6) >15) 0)
crc = (crc_value.word 16 << 1) ^ POLY;
else
crc_value.word1 6 <<= 1;
msg <<= 1;
}
}
return(crc_valu e.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.word1 6 = &H0 ' read ADC value and put into storage var
location_value. word16 = &H0
crc_value.word1 6 = 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

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

Similar topics

3
118832
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, which holds as true on reversal back to datetime. AM Example:
17
2895
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 knew db's and gave me long list of things to do with that particular database, first thing being that particular conversion. Truth is that I don't know a first thing about db's, let alone using mysql... I downloaded mysql form www.mysql.com and...
3
3108
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 (*.dsp), but doesn't create the solution (*.sln) file. Is there an automated way to convert an existing VS6 C++ *.dsw to a .NET *.sln?
4
1878
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
1963
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 database into Access 2003 but the Autoexec macro falls over on the query below. I have tried running it separayely and the computer just hangs. I realise there is a lot of code below, but I'm hoping somebody may know what they are looking for...
3
1652
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 application ( a mid size hospital's ADT software ). My current version of Access is 2000. I must now decide wether or not to install Access2003 on the PC that I use to develop these applications. The users will be converted to 3000 over the next 6...
0
1706
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 solution uses the following technologies - Windows Server 2003 Windows Mobile 2003 Windows XP Professional SP2 Windows 2000 Professional SP4 SQL Server 2000
2
2437
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 and views that kick off at different times. My Access 2000 database works well. Problem: I converted the database to Access 2003 am using ORACLE again as my back end (they have updated the drivers in Oracle to 9i). I an trying
6
1807
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 has not been able to convert any of them. These are just two example sources of many. What should I be doing to convert these samples, or should I reinstall VB.net 2003? Dennis D., http://www.dennisys.com/
7
2496
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 answers to. First, we have a lot of UserControls. I am getting the error "Type uc_mc_btn_footer is not defined." where uc_mc_btn_footer is the name of the UserControl. Also, on almost all of our UserControls the conversion has remmed out all my code...
0
8683
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8609
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9170
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9031
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8901
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6528
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4371
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
2336
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2007
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.