Migrating VarPtr from VB6 to VB.NET

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi

I am converting VB6 to VB. Net it is refereeing to DLL as follow. I am not
sure how I can convert it to VB.Net statement.

Declare Function Chain_DES Lib "chaindes.dll" (ByRef Data As Any, ByRef key
As Any, ByVal TripleDES As Short, ByVal Blocks As Integer, ByVal method As
Integer) As Integer

Appreciate any suggestions, I tried substituting Object for Any, well it
compiles but program doesn’t function correctly.


Thanks

Al
 
Al,
Consider using overloading.

If Chain_DES allows being called with either an Integer as Data or a String
as Data, then I would define 2 overloads. Something like:
Declare Function Chain_DES Lib "chaindes.dll" (ByRef Data As Integer,
ByRef key
As Any, ByVal TripleDES As Short, ByVal Blocks As Integer, ByVal method As
Integer) As Integer
Declare Function Chain_DES Lib "chaindes.dll" (ByRef Data As String, ByRef
key
As Any, ByVal TripleDES As Short, ByVal Blocks As Integer, ByVal method As
Integer) As Integer

It really depends on what actual types are accepted by the Data & key
parameters as to how to get your Declare statements to work.

Another alternative, with possibly more work, and possibly more crashes, is
to use a System.IntPtr and the members of
System.Runtime.InteropServices.Marshal. Again what actual types are accepted
by the Data & key parameters as to how to get IntPtr to work...

Hope this helps
Jay
 
Back
Top