Jump to content
Tuts 4 You

Delphi to VB6 code conversion


tarequl.hassan

Recommended Posts

tarequl.hassan

Hi

Can anyone convert this delphi code to BV6?

procedure TKeyGen.Button1Click(Sender: TObject);
const Const_Array : array[0..7] of Char = ('e','n','c','r','y','w','e','b');
Var
StrName, Part2, Code : string;
i, AL, Last_Char  : Integer;

begin

  Code  := '' ;
  StrName := Edit1.Text;
  If StrName = '' then
  Edit2.Text := 'Enter your Name !!!'
  else
  Begin
  For i := 0 to length(StrName) - 1 do
  begin
    AL := ((Ord(StrName[i + 1]) + (i) + Length(StrName) + Ord(Const_Array[(I and 80000007)])) mod 10) + 48;
    Code := Char (AL) + Code  ;
  end;

    Last_Char := ((Length(StrName) + 112) mod 10) + 48;
 Edit2.Text := Code + Char(Last_Char);
  end;
end;

 

 

THANKS

Delphi registration code.txt

Edited by tarequl.hassan (see edit history)
Link to post
  • 3 weeks later...
tarequl.hassan

Have anyone tried?

Link to post
tonyweb

@tarequl.hassan

I understand this is not what you want to hear but IMHO you should try converting it on your own, instead of asking others to do so for you. It will be more rewarding. :)
I mean: the code is not that difficult to understand and with a couple of online searches you would find the way to convert it, if you already know VB6.

Personally I think you would just need the following links to understand that code.

http://www.delphibasics.co.uk/Article.asp?Name=Arrays
http://www.delphibasics.co.uk/RTL.asp?Name=ord
http://www.delphibasics.co.uk/rtl.asp?name=char

Good luck!

Regards,
Tony

 

Edited by tonyweb (see edit history)
  • Like 1
Link to post
ToMKoL

Try this. I'm not sure if this is correct (haven't tried).

Procedure keygen_click()

Dim enc = "encryweb"

If (Len(Text1.Text) = 0) Then
    Text2.Text = "Enter some name!"
    Exit Sub
End If

For i = 1 to Len(Text1.Text):
     code = code & Chr(Asc(Mid(Text1.Text, i + 1, 1)) + i + Len(Text1.Text) + Asc(Mid(enc, (i mod 7), 1)) + 48)
Next i

code = code & Chr(((Len(Text1.Text) + 112) mod 10) + 48)

Text2.Text = code

Also I'm not sure why there is 'mod 10' in this line:
Ord(Const_Array[(I and 80000007)])) mod 10)
String is 8 chars so 'and ' will work like 'mod' in this case and give us current 'string[i]'.

  • Thanks 1
Link to post
T-rad

VB6 is not 0 based ( per the' i' starting with 1, not 0 in the for loop), therefore this will not work

code = code & Chr(Asc(Mid(Text1.Text, i + 1, 1)) + i + Len(Text1.Text) + Asc(Mid(enc, (i mod 7), 1)) + 48)

it will have to be something more like this like this providing the rest works

code = code & Chr(Asc(Mid(Text1.Text, i, 1)) + (i - 1) + Len(Text1.Text) + Asc(Mid(enc, (i mod 7), 1)) + 48)

also the Delphi code reads

Code := Char (AL) + Code  ;

so shouldn't the vb6  code read

code = Chr(Asc(Mid(Text1.Text, i, 1)) + (i - 1) + Len(Text1.Text) + Asc(Mid(enc, (i mod 7), 1)) + 48) & code

 just my thoughts...

T-rad

  • Like 1
Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...