VB6 to VB.Net - what am i doing wrong?

  • Thread starter Thread starter Salisha Khan
  • Start date Start date
S

Salisha Khan

Hey there,

Can anyone please help with this problem?

The function below works fine in VB6. For VB .NET the constants
vbFromUnicode and vbUnicode no longer exist. The problem is the
DecryptString method takes an ANSI String byref. In VB .NET you only have
Unicode strings. All the string format conversion methods for VB .NET return
the conversion in a Byte array not a string as in VB6. I can't pass a byte
array to the ecryptString method. I've tried using declare and dllImport to
declare the DecryptString as an ANSI function but it seems to have no
effect. Maybe because DecryptString works directly on the byref string
passed in instead of returning a string. In the .NET version here is my
Declare:

Private Declare Ansi Function DecryptString Lib

"AxInterop.TDCIPH32Lib.dll" Alias "DecryptString" _

(ByRef ciphertext As String, ByVal count As Integer) As Short

below is the VB6 version that works:

Private Function Decrypt(S As String, StrLength As Byte) As String

Dim count As Long, status As Integer, strCfr As String

Dim strANSIInput As String

Dim i As Integer

Dim Index As Integer

TDciph321.DESReset

' convert to hex string

For i = 1 To StrLength Step 2

strCfr = strCfr & Chr("&H" & Mid(S, i, 2))

Next

' convert to an ansi string

strCfr = StrConv(strCfr, vbFromUnicode)

' decrypt the string

status = TDciph321.DecryptString(strCfr, LenB(strCfr))

' convert back to Unicode

strANSIInput = StrConv(strCfr, vbUnicode)

Decrypt = strANSIInput

End Function

If anyone has any ideas that help I'd be greatly appreciative. Thanks in

advance.



Salisha
 
vbFromUnicode is 128 and vbUnicode 64 .

but...... personal I wouldn't even try to convert VB6 to VB.NET.

I would consider COM objects that are written in VB6 though.

Steve
 
Back
Top