Hello All,
I have tried multiple online tools to convert an VB6 (bas) file to
VB.NET file and no luck. I was hoping that someone could help me covert
this. I am new to the .NET world and still learning all help would be
greatly apperciated.
Attribute VB_Name = "Module1"
Option Explicit
Dim pass$
Dim Strg$
Function decrypt(ByVal H$) As String
Dim i As Integer, J$
pass$ = "THEFELDGROUP"
'H$ = the buffered encrypted data
H$ = Mid$(H$, 3, Val(Left$(H$, 2)))
' debuffer it
Strg$ = ""
For i = 1 To Len(H$) Step 2
J$ = Mid$(H$, i, 2)
Strg$ = Strg$ + Chr$(Val("&H" + J$))
Next
'Strg$ now contains the encrypted string, which you can now
'decrypt.
Call Crypt(pass$, Strg$)
'strg$ now is decrypted
decrypt = Strg$
End Function
Function Crypt(pass$, Strg$)
Dim a, b
Dim i As Integer
a = 1
For i = 1 To Len(Strg$)
b = Asc(Mid$(pass$, a, 1)): a = a + 1: If a Len(pass$) Then a =
1
Mid$(Strg$, i, 1) = Chr$(Asc(Mid$(Strg$, i, 1)) Xor b)
Next
End Function 16 5408
Noticed the name of this NG? Please post to the
microsoft.public.dotnet.languages.vb NG.
Willy.
<ma**********@gmail.comwrote in message
news:11**********************@i3g2000cwc.googlegro ups.com...
| Hello All,
| I have tried multiple online tools to convert an VB6 (bas) file to
| VB.NET file and no luck. I was hoping that someone could help me covert
| this. I am new to the .NET world and still learning all help would be
| greatly apperciated.
|
|
| Attribute VB_Name = "Module1"
| Option Explicit
|
| Dim pass$
| Dim Strg$
|
|
|
| Function decrypt(ByVal H$) As String
|
| Dim i As Integer, J$
|
| pass$ = "THEFELDGROUP"
|
| 'H$ = the buffered encrypted data
|
| H$ = Mid$(H$, 3, Val(Left$(H$, 2)))
|
| ' debuffer it
|
| Strg$ = ""
| For i = 1 To Len(H$) Step 2
| J$ = Mid$(H$, i, 2)
| Strg$ = Strg$ + Chr$(Val("&H" + J$))
| Next
|
| 'Strg$ now contains the encrypted string, which you can now
| 'decrypt.
|
| Call Crypt(pass$, Strg$)
|
| 'strg$ now is decrypted
|
| decrypt = Strg$
|
| End Function
|
| Function Crypt(pass$, Strg$)
| Dim a, b
| Dim i As Integer
|
| a = 1
| For i = 1 To Len(Strg$)
| b = Asc(Mid$(pass$, a, 1)): a = a + 1: If a Len(pass$) Then a =
| 1
| Mid$(Strg$, i, 1) = Chr$(Asc(Mid$(Strg$, i, 1)) Xor b)
| Next
|
| End Function
|
<ma**********@gmail.comwrote in message
news:11**********************@i3g2000cwc.googlegro ups.com...
I have tried multiple online tools to convert an VB6 (bas) file to
VB.NET file and no luck. I was hoping that someone could help me covert
this. I am new to the .NET world
And to the world of newsgroups too, by the looks of it...
Is there any particular reason that you posted a question regarding
converting VB6 to VB.NET to a C# newsgroup...?
Yes,
Actually I will be converting this to C#. Thought converting to VB.NET
might be easier. If anyone could help me convert this to C#, even
better :).
Thanks
Mark Rae wrote:
<ma**********@gmail.comwrote in message
news:11**********************@i3g2000cwc.googlegro ups.com...
I have tried multiple online tools to convert an VB6 (bas) file to
VB.NET file and no luck. I was hoping that someone could help me covert
this. I am new to the .NET world
And to the world of newsgroups too, by the looks of it...
Is there any particular reason that you posted a question regarding
converting VB6 to VB.NET to a C# newsgroup...?
<ma**********@gmail.comwrote in message
news:11**********************@e3g2000cwe.googlegro ups.com...
Yes,
Actually I will be converting this to C#.
Ah... what you need to do is to enable telepathy mode when posting on
newsgroups - if you're using Outlook or Outlook Express, it's under Tools,
Options...
That way, everybody will just instinctively understand what you really
mean...
Use the VB.NET upgrade wizard (with Visual Studio) to convert this.
Hopefully, it can handle those nasty ancient VB1 type specifiers...
--
David Anton www.tangiblesoftwaresolutions.com
Instant C#: VB to C# converter
Instant VB: C# to VB converter
Instant C++: C#/VB to C++ converter
Instant Python: VB to Python converter
"ma**********@gmail.com" wrote:
Hello All,
I have tried multiple online tools to convert an VB6 (bas) file to
VB.NET file and no luck. I was hoping that someone could help me covert
this. I am new to the .NET world and still learning all help would be
greatly apperciated.
Attribute VB_Name = "Module1"
Option Explicit
Dim pass$
Dim Strg$
Function decrypt(ByVal H$) As String
Dim i As Integer, J$
pass$ = "THEFELDGROUP"
'H$ = the buffered encrypted data
H$ = Mid$(H$, 3, Val(Left$(H$, 2)))
' debuffer it
Strg$ = ""
For i = 1 To Len(H$) Step 2
J$ = Mid$(H$, i, 2)
Strg$ = Strg$ + Chr$(Val("&H" + J$))
Next
'Strg$ now contains the encrypted string, which you can now
'decrypt.
Call Crypt(pass$, Strg$)
'strg$ now is decrypted
decrypt = Strg$
End Function
Function Crypt(pass$, Strg$)
Dim a, b
Dim i As Integer
a = 1
For i = 1 To Len(Strg$)
b = Asc(Mid$(pass$, a, 1)): a = a + 1: If a Len(pass$) Then a =
1
Mid$(Strg$, i, 1) = Chr$(Asc(Mid$(Strg$, i, 1)) Xor b)
Next
End Function
Thanks for the info David but I have already tried that and it made it
look even worse.
Any Help?
David Anton wrote:
Use the VB.NET upgrade wizard (with Visual Studio) to convert this.
Hopefully, it can handle those nasty ancient VB1 type specifiers...
--
David Anton www.tangiblesoftwaresolutions.com
Instant C#: VB to C# converter
Instant VB: C# to VB converter
Instant C++: C#/VB to C++ converter
Instant Python: VB to Python converter
"ma**********@gmail.com" wrote:
Hello All,
I have tried multiple online tools to convert an VB6 (bas) file to
VB.NET file and no luck. I was hoping that someone could help me covert
this. I am new to the .NET world and still learning all help would be
greatly apperciated.
Attribute VB_Name = "Module1"
Option Explicit
Dim pass$
Dim Strg$
Function decrypt(ByVal H$) As String
Dim i As Integer, J$
pass$ = "THEFELDGROUP"
'H$ = the buffered encrypted data
H$ = Mid$(H$, 3, Val(Left$(H$, 2)))
' debuffer it
Strg$ = ""
For i = 1 To Len(H$) Step 2
J$ = Mid$(H$, i, 2)
Strg$ = Strg$ + Chr$(Val("&H" + J$))
Next
'Strg$ now contains the encrypted string, which you can now
'decrypt.
Call Crypt(pass$, Strg$)
'strg$ now is decrypted
decrypt = Strg$
End Function
Function Crypt(pass$, Strg$)
Dim a, b
Dim i As Integer
a = 1
For i = 1 To Len(Strg$)
b = Asc(Mid$(pass$, a, 1)): a = a + 1: If a Len(pass$) Then a =
1
Mid$(Strg$, i, 1) = Chr$(Asc(Mid$(Strg$, i, 1)) Xor b)
Next
End Function
Mannit,
I assume that this is a troll message to let people say that C# is better.
In my idea you don't know much from VB otherwise you would not have included
this in your message.
'H$ = the buffered encrypted data
Cor
Yeah, I perfer C# over VB.NET anytime. I did not even noticed that I
had that in the statement.
So, has anyone converted this so far?
:( -If I had the ability to cry on this forum, I would make this
face cry.
Cor Ligthert [MVP] wrote:
Mannit,
I assume that this is a troll message to let people say that C# is better.
In my idea you don't know much from VB otherwise you would not have included
this in your message.
'H$ = the buffered encrypted data
Cor
On Oct 9, 3:01 pm, manmit.wa...@gmail.com wrote:
Attribute VB_Name = "Module1"
Option Explicit
Dim pass$
Dim Strg$
These are just strings, so declare them normally in C#:
string pass;
string Strg;
>
Function decrypt(ByVal H$) As String
This is a method that takes a string and returns a string:
public string decrypt(string h)
Dim i As Integer, J$
An integer and a string:
int i;
string J;
>
pass$ = "THEFELDGROUP"
This is just string assignment.
>
'H$ = the buffered encrypted data
Same here
H$ = Mid$(H$, 3, Val(Left$(H$, 2)))
Here, the Mid$ statement is taking a substring of a string so in .Net
it would be the string.Substring method. The Left$ method would also
be replaced by the Substring method.
' debuffer it
Strg$ = ""
String assignment again.
For i = 1 To Len(H$) Step 2
For loop:
for (int i = 1; i <= H.Length; i += 2)
J$ = Mid$(H$, i, 2)
Strg$ = Strg$ + Chr$(Val("&H" + J$))
Next
More Substring activity, along with some string concatenation.
The remaining method is just more of the same. It should be a fairly
straight forward conversion. If you have a specifc problem, you can
post those questions for help here.
Good Luck.
Thanks Chris for the help.
I have something that I bieleve might be on the right track. But
somehow it is still not working.
TEST Data - H = 200C3820342C292A24377E
Output decrypted H should = Xperience1
But I am getting the following - ♀8 4,)*$7~
public string Mydecrypt(string H)
{
long i;
string J;
const string pass = "THEFELDGROUP";
H = H.Substring(2,
Convert.ToInt32(Microsoft.VisualBasic.Conversion.V al(H.Substring(0,
2))));
string Strg = "";
int tempFor1 = H.Length;
for (i = 1; i <= tempFor1; i += 2)
{
int t = Convert.ToInt32(i-1);
J = H.Substring(t, 2);
Strg = Strg +
(char)(Microsoft.VisualBasic.Conversion.Val("&H" + J));
}
myCrypt(pass, Strg);
return Strg;
}
public object myCrypt(string pass, string Strg)
{
int a;
int b;
long i = 0;
a = 1;
long tempFor1 = Strg.Length;
for (i = 1; i <= tempFor1; i++)
{
b = System.Convert.ToInt32(pass[a - 1]);
a = a + 1;
if (a pass.Length)
{
a = 1;
}
Strg += Strg.Remove(Convert.ToInt32(i - 1),
1).Insert(Convert.ToInt32(i - 1),
((char)(System.Convert.ToInt32(Strg[Convert.ToInt32(i - 1)]) ^
b)).ToString());
}
return Strg;
}
<ma**********@gmail.comwrote:
Thanks Chris for the help.
I have something that I bieleve might be on the right track. But
somehow it is still not working.
TEST Data - H = 200C3820342C292A24377E
Output decrypted H should = Xperience1
Well, the converted code is pretty horrible - I've tidied it up a bit
and I think this is *nearly* what you want. However, it only decrypts
to Xperience1 when you get rid of the 20 from the front of the test
data. Are you sure your original data is correct?
Note that your "encryption" is very weak, and that it also doesn't
support Unicode properly.
using System;
class Test
{
static void Main()
{
Console.WriteLine (Decrypt("THEFELDGROUP",
"0C3820342C292A24377E"));
}
static byte[] ParseHex(string text)
{
byte[] ret = new byte[text.Length/2];
for (int i=0; i < ret.Length; i++)
{
ret[i] = Convert.ToByte(text.Substring (i*2, 2), 16);
}
return ret;
}
static string Decrypt (string password,
string encrypted)
{
byte[] binary = ParseHex(encrypted);
char[] chars = new char[binary.Length];
for (int i=0; i < chars.Length; i++)
{
chars[i] = (char)(binary[i] ^ password[i%password.Length]);
}
return new string(chars);
}
}
--
Jon Skeet - <sk***@pobox.com> http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Thanks Jon,
This helped a lot, to answer your question about the "20" in the front
of the data. I basically added the following to my application:
temp =
temp.Substring(2,Convert.ToInt32(Microsoft.VisualB asic.Conversion.Val(temp.Substring(0,2))));
As you already know, this will trim of the first two characters of the
string.
Now I usually don't ask people for help but this one was a total brain
teaser. If you do not mind, can you please explain to me where each
line of your C# fits in with the VB6 code I have posted on top of this
post?
Thanks again Jon
<ma**********@gmail.comwrote:
This helped a lot, to answer your question about the "20" in the front
of the data. I basically added the following to my application:
temp =
temp.Substring(2,Convert.ToInt32(Microsoft.VisualB asic.Conversion.Val(temp.Substring(0,2))));
As you already know, this will trim of the first two characters of the
string.
Actually, it'll do quite a bit more than that, by the looks of it. Far
simpler is:
temp = temp.Substring(2);
Ah yes - I hadn't seen this line:
H$ = Mid$(H$, 3, Val(Left$(H$, 2)))
I don't see what the point of that bit is, to be honest - it just gives
the length of the rest of the string. If you really need it, use:
temp = temp.Substring (2, int.Parse(temp.Substring(0, 2));
There's no need for all these calls to the Visual Basic dll.
Now I usually don't ask people for help but this one was a total brain
teaser. If you do not mind, can you please explain to me where each
line of your C# fits in with the VB6 code I have posted on top of this
post?
Well, I didn't do a line by line conversion. I thought about what the
VB6 code is doing in chunks, and converted the chunks. There are two
basic operations here:
1) Parse the hex values, essentially as bytes (but then treat them as
characters, which will give a different result in .NET than in VB6, but
never mind). In the C# version this is performed by the ParseHex method
which returns an array of bytes. We parse each pair of characters using
Convert.ToByte, specifying 16 as the base (for hex).
2) Take each value (byte in the C# code, character in the original VB6
code) and XOR it with the value of the corresponding character in the
password. The VB6 version kept an extra counter to wrap round if it
reaches the end of the password, but in the C# version I just use the
remainder operator (%) to do that without having a separate counter.
If any of it stumps you, I can go through individual bits in more
detail.
--
Jon Skeet - <sk***@pobox.com> http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Thanks Jon, your explaination makes it a little clearer. I do have a
question though, in my original VB6 code, there was a method called
Crypt, which took a 'key' and a 'string value'. The thing I don't
understand is does this method actually encrypts a string, because I do
not see it returning anything. Please tell me if I am wrong or
incorrect.
I have also took your code and see if I can create an Encryption Method
just to test it out as well learn C# even more. Below is what I have so
far.
static byte[] deParseHex(string text)
{
byte[] ret = new byte[text.Length * 2];
for (int i = 0; i < ret.Length; i++)
{
ret[i] = Convert.ToByte(text.Substring(i * 2), 16);
}
return ret;
}
static string Encrypt(string password, string decrypted)
{
byte[] binary = deParseHex(decrypted);
char[] chars = new char[binary.Length];
for (int i = 0; i < chars.Length; i++)
{
chars[i] = (char)(password[i % password.Length] ^
binary[i]);
}
return new string(chars);
}
Jon wrote:
If any of it stumps you, I can go through individual bits in more
detail.
Thanks Jon, your explanation makes it a little clearer. I do have a
question though, in my original VB6 code, there was a method called
Crypt, which took a 'key' and a 'string value'. The thing I don't
understand is does this method actually encrypts a string, because I do
not see it returning anything. Please tell me if I am wrong or
incorrect.
I have also taken your code and see if I can create an Encryption
Method just to test it out as well learn C# even more. Below is what I
have so far.
static byte[] deParseHex(string text)
{
byte[] ret = new byte[text.Length * 2];
for (int i = 0; i < ret.Length; i++)
{
ret[i] = Convert.ToByte(text.Substring(i * 2), 16);
}
return ret;
}
static string Encrypt(string password, string decrypted)
{
byte[] binary = deParseHex(decrypted);
char[] chars = new char[binary.Length];
for (int i = 0; i < chars.Length; i++)
{
chars[i] = (char)(password[i % password.Length] ^
binary[i]);
}
return new string(chars);
}
<ma**********@gmail.comwrote:
Thanks Jon, your explanation makes it a little clearer. I do have a
question though, in my original VB6 code, there was a method called
Crypt, which took a 'key' and a 'string value'. The thing I don't
understand is does this method actually encrypts a string, because I do
not see it returning anything. Please tell me if I am wrong or
incorrect.
I don't know enough about VB to say for sure, but I suspect it was
changing the string "in-place" with this:
Mid$(Strg$, i, 1) = Chr$(Asc(Mid$(Strg$, i, 1)) Xor b)
You *could* do that with a StringBuilder, and change the data in place,
but it's neater just to return a new string.
I have also taken your code and see if I can create an Encryption
Method just to test it out as well learn C# even more. Below is what I
have so far.
Your "deParseHex" is incorrect. It should be taking a byte array and
returning a string - effectively producing a hex representation of what
you give it.
You then need to change your Encrypt method to do the "encryption"
(within a byte array, hoping that Unicode isn't going to be a problem
for you) and call deParseHex (or "ConvertToHex" as I'd call it) *after*
that.
Basically, to work out the encryption process you need to reverse the
order and action of the decryption process. So as the decryption
process is:
o Start with string
o Convert string into bytes by treating each pair of characters as the
hex representation of a byte
o XOR each byte with the value of the corresponding password character
o Convert bytes into a string
then the encryption process is:
o Convert string into bytes
o XOR each byte with the value of the corresponding password character
o Convert bytes into string by converting each byte into its hex
representation
o End with string
--
Jon Skeet - <sk***@pobox.com> http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Newbee Adam |
last post by:
I have been reading in help how I need to use decimal becuase currency does
not exist like I used in vb6.
I had a difficult time on google and msdn finding how or if I can take the
value of text...
|
by: Megat |
last post by:
I'm trying to create a conversion program, that convert a simple
proprietry programming language to an international standard
languange, using Visual C++. Need some help from those who has...
|
by: prabha |
last post by:
Hello Everybody,
I have to conert the word doc to multiple html files,according to the templates in the word doc.
I had converted the word to xml.Also through Exsl ,had finished the multiple...
|
by: Jake Jessup |
last post by:
A client wants me to do a conversion from Access 2.0 (yeah, I know, unreal).
The problem is, she doesn't have the install disks and I haven't had a copy
of 2.0 in years.
If some kind should...
|
by: Robert |
last post by:
I have a series of web applications (configured as separate applications) on
a server.
There is a main application at the root and then several virtual directories
that are independant...
|
by: sam_cit |
last post by:
Hi,
I needed help in converting a character to the correspoding
hexadecimal values, like the following example,
ASCII value : ABC
Hex Code Value : %41%42%43...
whats the logic of conversion...
|
by: Mhel |
last post by:
Hi everyone! I need some help in Converting Infix to postfix.I need a program that would do it.
Please, I really need help.
|
by: Hank Stalica |
last post by:
I'm having this weird problem where my code does the following
conversion from string to float:
27000000.0 -27000000.00
2973999.99 -29740000.00
2989999.13 -2989999.25
The number on the left...
|
by: helpwithcode |
last post by:
Hi people,
I am just learning java.I have been creating a project which involves JDBC Connectivity.I find that the statements,
String string_dob=text_dob.getText();
//Converting string to...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
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
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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...
| |