Convert to Vb.Net

Y

YXQ

Hello,
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!

The C# code
*****************************************************
byte[] nnValue;
string digits = "BCDFGHJKMPQRTVWXY2346789";
int n, hi, low, v;
int dLen = 29;
int sLen = 15;
char[] KeyDestination = new char[32];
char[] Source = new char[15];

// Get the 15 bytes of raw HEX
for (int b = 0; b < 15; b++ )
{
char x = (char)nnValue[b + 52];
Source = x;
}

// Begin decoding
for(int i = dLen-1; i >= 0; i--)
{
if(((i+1) % 6) == 0)
{
KeyDestination = '-';
KeyDestination[dLen] = '\0';
}
else
{
n = sLen - 1;
hi = 0;
do
{
low = Source[n];
v = hi << 8;
v |= low;
Source[n] = (char)(v / 24);

hi =v % 24;
}while((--n) >= 0);
KeyDestination = digits[v % 24];
KeyDestination[dLen] = '\0';
}
}
// Display key on screen
for (int x=0; x< KeyDestination.Length; x++)
{
temp += KeyDestination[x].ToString();
}
}
*****************************************************

The converted vb.net code
******************************************************
Dim nnValue() As Byte
Dim digits As String = "BCDFGHJKMPQRTVWXY2346789"
Dim n, hi, low, v As Integer
Dim dLen As Integer = 29
Dim sLen As Integer = 15
Dim KeyDestination(32) As Char
Dim [Source](15) As Char

' Get the 15 bytes of raw HEX
Dim b As Integer
Dim x As Char
For b = 0 To 14
x = CChar(nnValue((b + 52)).ToString)
[Source](b) = x
Next b

' Begin decoding
Dim i As Integer
For i = dLen - 1 To 0 Step -1
If (i + 1) Mod 6 = 0 Then
KeyDestination(i) = "-"
KeyDestination(dLen) = ControlChars.NullChar
Else
n = sLen - 1
hi = 0
Do
low = Microsoft.VisualBasic.Val([Source](n))
v = hi << 8
v = v Or low

[Source](n) = CChar(CStr(v / 24))
hi = v Mod 24
n = n - 1
Loop While n >= 0
KeyDestination(i) = digits.Chars((v Mod 24))
KeyDestination(dLen) = ControlChars.NullChar
End If
Next i
Dim temp As String
Dim y As Integer
For y = 0 To KeyDestination.Length - 1
temp += KeyDestination(y).ToString()
Next y
 
Y

YXQ

Hello,
I found this code is error.

Source[n] = (char)(v / 24); // i converted to "Source(n) =
Microsoft.VisualBasic.ChrW(v / 24)"
 

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