473,385 Members | 1,973 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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

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



Nov 22 '05 #1
1 2337
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
"Salisha Khan" <sk***@mdsp.org> wrote in message
news:Js***************@news.abs.net...
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



Nov 22 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Graham Mattingley | last post by:
I am trying to count the records in a database, and make an array from the answer this is the code strQuery = "SELECT count(*) FROM resort where island_id= '"&island_drop&"' ;" Set...
4
by: Simom Thorpe | last post by:
Hi, I'm trying to insert a line into a MS access DB using ASP on IIS 5. This is the line: con.execute "INSERT INTO newProds(title,desc,catcode) VALUES ('Champagne Muff Scarf','','AC304B')"...
1
by: coolsti | last post by:
I am trying to let the user drag a rectangle over an image, which will then let the user zoom in on the dragged area. However, I am doing something wrong in implementing the onmousedown and...
2
by: Aaron Ackerman | last post by:
I cannot a row to this bound DataGrid to SAVE MY LIFE! I have tried everything and I am at a loss. The using goes into add mode with the add button adds his data then updates with the update...
5
by: Simon Brooke | last post by:
This is supposed to be a very simple XSL stylesheet to strip styling information out of HTML documents - it could not be more basic. And yet, it doesn't work. I'm obviously getting something very...
8
by: watkinsdev | last post by:
Hi, I have created a mesh class in visual studio 6.0 c++. I can create a device, render objects and can edit the objects by for instancnce selecting a cluster of vertices and processing the...
0
by: shapper | last post by:
Hello, I am creating a class with a control. I compiled the class and used it on an Asp.Net 2.0 web site page. I can see the begin and end tags of my control (<oland </ol>) but somehow the...
16
by: SirG | last post by:
I'm looking for an explanation of why one piece of code works and another does not. I have to warn you that this is the first piece of Javascript I've ever written, so if there is a better way or a...
10
by: DavidSeck.com | last post by:
Hi, I am working with the Facebook API right now, an I have kind of a problem, but I don't know what I am doing wrong. So I have a few arrays, f.ex.: User albums: array(2) {
34
by: raphfrk | last post by:
This program should copy one file onto the other. It works if I compile it with gcc to a cygwin program. However, if I compile it with the -mno-cygwin option, it doesn't work (this targets native...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.