Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hi there guys, I wasn't sure which area to post in, so I thought this one best.

 

I'm currently writing an encryption program side by side in Java and VB.NET, to compare performance differences and generally get the hang of Java (I'm new to it). Problem is, I have this code to initialize the encryption class in VB:

 

Dim NewEnc(1024) As ClassEnc6

       For Num = 1 To UBound(NewEnc)
           NewEnc(Num) = New ClassEnc6("encryptionkey")
       Next

 

How do I recreate this in Java? I've tried all sorts, and any Java documentation I can find is way over my head. Any ideas?

Chaos is merely logic beyond human comprehension
Posted (edited)

ClassEnc6 NewEnc() = new ClassEnc6(1024);

 

for(int num = 1; num < 1024; num++)

{

NewEnc(num) = new ClassEnc6("encryptionkey");

}

 

I don't know the ubound command in java. It could be NewEnc.GetLength

 

Edit: there might be a semicolon after num++. I have to brush up my Java/C++ skills. Haven't used them in so long (VB.NET is addicting :D)

Edit2: Also I'm assuming you know how to create the basic program (just to get it running.. ex; Creating the public static void main(String args[]) function...etc). if you need help on that I"ll post some code.

Also, i'd recommend JCreator Pro, it's a 30 day trial, however Xinox software seems to release new versions all the time, and if you give them your email they'll send you updates and let you "try" their new software for an extra 30 days. What they don't realize is, this is a cheap way to keep the software forever (legally).

 

-The Pentium Guy

Edited by ThePentiumGuy

My VB.NET Game Programming Tutorial Site (GDI+, Direct3D, Tetris [coming soon], a full RPG.... you name it!)

vbprogramming.8k.com

My Project (Need VB.NET Programmers)

http://workspaces.gotdotnet.com/ResolutionRPG

Posted

There's no ; behind the last argument in a for loop. And you're sure that this class also exists in Java(not sure if this is a custom or VB .net class)

Some mistakes though:

 

ClassEnc6[] NewEnc = new ClassEnc6[1024];

 

for(int num = 0; num < NewEnc.Length; num++) //Arrays begin at index 0

{

NewEnc[num] = new ClassEnc6("encryptionkey");

}

 

And I would recommend JBuilder Personal from borland as it is free. :)

For questions about VS .net extensibility, please fire at me! :)

For readability, please use the [ CS][/CS ] tags

Posted

There's no ; behind the last argument in a for loop. And you're sure that this class also exists in Java(not sure if this is a custom or VB .net class)

Ah. Thanks for clarifying. Yeah it should be a custom class, I haven't heard of a ClassEnc6 in vb.net or java.

 

I'm pretty sure it doesn't matter where the square brackets go.

Edit: Heh, corrected myself. Square brackets. I forgot about that.

 

Yeah I was going to mention the index. CyroEnix, it would be better if you started your array with index 0 and ended with 1023 (unless you wanted 1025 elements in your array by ending with 1025), remember, 0 is an element.

 

-The Pentium Guy

My VB.NET Game Programming Tutorial Site (GDI+, Direct3D, Tetris [coming soon], a full RPG.... you name it!)

vbprogramming.8k.com

My Project (Need VB.NET Programmers)

http://workspaces.gotdotnet.com/ResolutionRPG

Posted
But declaring Array[1024] gives an array of 1024 elements. 0 to 1023.

For questions about VS .net extensibility, please fire at me! :)

For readability, please use the [ CS][/CS ] tags

Posted

That's what I said ;).

 

Yeah I was going to mention the index. CyroEnix, it would be better if you started your array with index 0 and ended with 1023 (unless you wanted 1025 elements in your array by ending with 1025), remember, 0 is an element.

My VB.NET Game Programming Tutorial Site (GDI+, Direct3D, Tetris [coming soon], a full RPG.... you name it!)

vbprogramming.8k.com

My Project (Need VB.NET Programmers)

http://workspaces.gotdotnet.com/ResolutionRPG

Posted (edited)

ThePentiumGuy, Himo... What can I say? You guys are the dog's! I mean, have you ever been so grateful for some help that you'd be willing to go to someones door to thank them personally? That's where I am now - of course, there's the transport issue, and I don't think you'd be too chuffed with a new stalker.

 

Enough of the ranting, thanks a million - gonna start playing with that code right away!

 

 

On the note of arrays, since .NET's removal of manual dimming (3 to 6, for example), I've been dimensioning them one higher than usual - in this case, from 0 to 1024 and ignoring the 0. I find this especially useful to find out if there's anything in an array - as trying a Ubound() on an undimensioned array tends to make VBN scream like a girl.

Edited by CryoEnix
Chaos is merely logic beyond human comprehension
Posted

How bout using collections? They start at 1 and they're easy to work with.

Dim c as new collection

 

c.add(myclass)

 

But you can't control where that item goes unfortunately, it goes "on top". So c.Item(1) would be myclass.

 

.NET's removal of manual dimming (3 to 6, for example),

Those were the good old days.... :D.

 

-TPG

My VB.NET Game Programming Tutorial Site (GDI+, Direct3D, Tetris [coming soon], a full RPG.... you name it!)

vbprogramming.8k.com

My Project (Need VB.NET Programmers)

http://workspaces.gotdotnet.com/ResolutionRPG

Posted

What about Vectors? They're in Java.Util.Vector (I think, has been a while) and functions like dynamic uber-arrays. They have a InsertAt/RemoveAt function and a can contain everything, thanks to explicit casting, I love it.

Just an extension.

For questions about VS .net extensibility, please fire at me! :)

For readability, please use the [ CS][/CS ] tags

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...