Pleae assist me to view the code

Y

yxq

Hello,
There are the C# codes£¬but i know a little about C#, i want to convert to
VB.NET, i have try the
url(http://authors.aspalliance.com/aldotnet/examples/translate.aspx), but
the converted codes will not work. Thank you!


char[] Source = new char[15]
int n, hi, low, v;

do
{
low = Source[n]; // I use Microsoft.VisualBasic.Val(Source(n)) in
vb.net
v = hi << 8; // << what meaning?
v |= low; // |= what meaning?

Source[n] = (char)(v % 24); // % is Mod?
Source[n] = (char)(v / 24);
hi =v % 24;
}while((--n) >= 0); // --n>=0 what meaning£¿
 
P

Peter van der Goes

yxq said:
Hello,
There are the C# codes£¬but i know a little about C#, i want to convert to
VB.NET, i have try the
url(http://authors.aspalliance.com/aldotnet/examples/translate.aspx), but
the converted codes will not work. Thank you!


char[] Source = new char[15]
int n, hi, low, v;

do
{
low = Source[n]; // I use Microsoft.VisualBasic.Val(Source(n)) in
vb.net
v = hi << 8; // << what meaning?
v |= low; // |= what meaning?

Source[n] = (char)(v % 24); // % is Mod?
Source[n] = (char)(v / 24);
hi =v % 24;
}while((--n) >= 0); // --n>=0 what meaning£¿
do

{

low = Source[n]; // I use Microsoft.VisualBasic.Val(Source(n)) in vb.net

v = hi << 8; // << what meaning?

// Shift the bits in variable hi left 8

v |= low; // |= what meaning?

// perform bitwise OR on v and low, assign the result to v

Source[n] = (char)(v % 24); // % is Mod?

// Yes, % is the C# modulus operator

Source[n] = (char)(v / 24);

hi =v % 24;

}while((--n) >= 0); // --n>=0 what meaning£¿

// -- before the operand is the prefix decrement operator.

// If subtracts 1 from n before testing to see if n is >= 0
 
C

Chris Dunaway

v = hi << 8; // << what meaning?

That is the Shift Left operator and it is the same in VB.Net 2003
v |= low; // |= what meaning?

This is the bitwise Or operator. In VB.Net 2003, the code would be

v = v Or low
Source[n] = (char)(v % 24); // % is Mod?
Yes

}while((--n) >= 0); // --n>=0 what meaning£¿

The (--n) means to decrement n BEFORE checking the condition in the while
loop. This is the equivalent VB code:

do

'Other code here

n = n - 1
loop while n >= 0

--
Chris

dunawayc[AT]sbcglobal_lunchmeat_[DOT]net

To send me an E-mail, remove the "[", "]", underscores ,lunchmeat, and
replace certain words in my E-Mail address.
 
Y

YXQ

Thank you, my converted codes are below, but dont work yet!!!!!
************************************
Do
low = Microsoft.VisualBasic.Val(Source(n))
v = hi < 8
v = v Or low
Source(n) = (CChar(CStr(v Mod 24)))
Source(n) = CChar(CStr(v / 24))
hi = v Mod 24
n = n - 1
Loop While n >= 0
******************************************

Chris Dunaway said:
v = hi << 8; // << what meaning?

That is the Shift Left operator and it is the same in VB.Net 2003
v |= low; // |= what meaning?

This is the bitwise Or operator. In VB.Net 2003, the code would be

v = v Or low
Source[n] = (char)(v % 24); // % is Mod?
Yes

}while((--n) >= 0); // --n>=0 what meaning£¿

The (--n) means to decrement n BEFORE checking the condition in the while
loop. This is the equivalent VB code:

do

'Other code here

n = n - 1
loop while n >= 0

--
Chris

dunawayc[AT]sbcglobal_lunchmeat_[DOT]net

To send me an E-mail, remove the "[", "]", underscores ,lunchmeat, and
replace certain words in my E-Mail address.
 
C

Chris Dunaway

Do
low = Microsoft.VisualBasic.Val(Source(n))

I don't think this line is right. You might try CInt(Source(n))
v = hi < 8

I think this should be v = hi << 8
v = v Or low
Source(n) = (CChar(CStr(v Mod 24)))
Source(n) = CChar(CStr(v / 24))
hi = v Mod 24
n = n - 1
Loop While n >= 0
******************************************

What is this code supposed to do?

--
Chris

dunawayc[AT]sbcglobal_lunchmeat_[DOT]net

To send me an E-mail, remove the "[", "]", underscores ,lunchmeat, and
replace certain words in my E-Mail address.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top