Migrating VarPtr from VB6 to VB.NET

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
 
J

Jay B. Harlow [MVP - Outlook]

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top