473,396 Members | 2,024 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,396 software developers and data experts.

Convert to Vb.Net

YXQ
Hello,
i want to convert to
VB.NET, i have try the
url(http://authors.aspalliance.com/aldot...ranslate.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[b] = x;
}

// Begin decoding
for(int i = dLen-1; i >= 0; i--)
{
if(((i+1) % 6) == 0)
{
KeyDestination[i] = '-';
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[i] = 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
Nov 21 '05 #1
1 3324
YXQ
Hello,
I found this code is error.

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

"YXQ" <ga***@163.com> дÈëÏûÏ¢ÐÂÎÅ:Ou**************@TK2MSFTNGP09.phx.gbl ...
Hello,
i want to convert to
VB.NET, i have try the
url(http://authors.aspalliance.com/aldot...ranslate.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[b] = x;
}

// Begin decoding
for(int i = dLen-1; i >= 0; i--)
{
if(((i+1) % 6) == 0)
{
KeyDestination[i] = '-';
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[i] = 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

Nov 21 '05 #2

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

Similar topics

19
by: Lauren Quantrell | last post by:
I have a stored procedure using Convert where the exact same Convert string works in the SELECT portion of the procedure but fails in the WHERE portion. The entire SP is listed below....
1
by: Logan X via .NET 247 | last post by:
It's official....Convert blows. I ran a number of tests converting a double to an integer usingboth Convert & CType. I *ASSUMED* that CType would piggy-back ontop of Convert, and that performance...
4
by: Eric Lilja | last post by:
Hello, I've made a templated class Option (a child of the abstract base class OptionBase) that stores an option name (in the form someoption=) and the value belonging to that option. The value is...
7
by: whatluo | last post by:
Hi, all I'm now working on a program which will convert dec number to hex and oct and bin respectively, I've checked the clc but with no luck, so can anybody give me a hit how to make this done...
3
by: Convert TextBox.Text to Int32 Problem | last post by:
Need a little help here. I saw some related posts, so here goes... I have some textboxes which are designed for the user to enter a integer value. In "old school C" we just used the atoi function...
7
by: patang | last post by:
I want to convert amount to words. Is there any funciton available? Example: $230.30 Two Hundred Thirty Dollars and 30/100
4
by: Edwin Knoppert | last post by:
In my code i use the text from a textbox and convert it to a double value. I was using Convert.ToDouble() but i'm used to convert comma to dot. This way i can assure the text is correct. However...
1
by: johnlim20088 | last post by:
Hi, Currently I have 6 web projects located in Visual Source Safe 6.0, as usual, everytime I will open solution file located in my local computer, connected to source safe, then check out/check in...
6
by: Ken Fine | last post by:
This is a basic question. What is the difference between casting and using the Convert.ToXXX methods, from the standpoint of the compiler, in terms of performance, and in other ways? e.g. ...
0
Debadatta Mishra
by: Debadatta Mishra | last post by:
Introduction In this article I will provide you an approach to manipulate an image file. This article gives you an insight into some tricks in java so that you can conceal sensitive information...
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: 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
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
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...
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,...
0
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...

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.