Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > VB6/VB.Net Programming Question - what am i doing wrong?

Reply
Thread Tools

VB6/VB.Net Programming Question - what am i doing wrong?

 
 
Salisha Khan
Guest
Posts: n/a
 
      07-31-2003
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









 
Reply With Quote
 
 
 
 
JohnFol
Guest
Posts: n/a
 
      08-01-2003
I think you already have a reply on Google.

http://groups.google.com/groups?hl=e...readm=04ea01c3
579c%24d3daea80%24a101280a%40phx.gbl&rnum=1&prev=/groups%3Fq%3Dansi%2Bunicod
e%2BvbFromUnicode%26hl%3Den%26lr%3D%26ie%3DUTF-8%26oe%3DUTF-8%26scoring%3Dd


"Salisha Khan" <(E-Mail Removed)> wrote in message
news:3saWa.8$(E-Mail Removed)...
> 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
>
>
>
>
>
>
>
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Improving page layout when doing elementary CGI programming. Ted Byers Perl Misc 5 08-06-2009 09:58 PM
C (functional programming) VS C++ (object oriented programming) Joe Mayo C Programming 168 10-22-2007 01:00 AM
Can Your Programming Language Do This? Joel on functional programming and briefly on anonymous functions! Casey Hawthorne Python 4 08-04-2006 05:23 AM
systems programming versus application programming Matt Java 35 07-22-2004 08:10 AM
RIP question (Im doing my ccna) Martin Cisco 7 04-26-2004 12:30 PM



Advertisments