thanks patrick,
The only thing thats strange is that I seem to get an differend output from
the dll if I use .net or vb6.
example if i run the opencom_click (it opens the com connection):
Private Sub OpenCom_Click()
Dim dwRC As Long
Dim dwComPort As Long
dwComPort = SelectCOMcb.ListIndex
'Open the com port
dwRC = csp2Init(dwComPort) ' this gives me a 0 in vb6 and
8975933078237085696 in vb.net
If dwRC <> STATUS_OK Then 'i need to get a 0 to get past this if
WriteToLog "Could Not Open COM" & CStr(dwComPort + 1)
Else
WriteToLog "COM" & CStr(dwComPort + 1) & " Opened"
'Disable the open button
OpenCom.Enabled = False
CloseCom.Enabled = True
'Disable COM Select
SelectCOMcb.Enabled = False
bComConnected = True
'Register the callback when the device is present.
'Status = csp2StartPolling(AddressOf CallBackDataAvailable)
End If
'Start the CTS State Timer
CTSStateTimer.Enabled = True
UpdateMainFormCtrls
End Sub
this is the function in the dll
in vb.net I've made a module where i put the functions in.
Declare Function csp2Init Lib "csp2.dll" (ByVal nComPort As Long) As Long
It seem like all the csp2.dll functions are given me other values in vb.net.
What am i doing wrong?
thanks
[quoted text, click to view] "Patrick Steele" wrote:
> In article <2EDEF0CA-6069-4A74-A08E-AF1E7D93BBA3@microsoft.com>,
> steve@discussions.microsoft.com says...
> > hi,
> >
> > I bought me a symbol CS1504 scanner to use the scanner there is an sdk with
> > an C++ dll and an example code written in vb6 to bind the dll to the vb6 app.
> >
> > I got my app running in vb6 but like to rebuild the thing so i can use it in
> > vb.net.
> > If I just open the app in visual studio 2005 I get an error and It just
> > shuts down.
> >
> > Do i need to convert the C++ dll?
> > How do I get the DLL to work in vb.net?
>
> Assembly.LoadFrom is only for loading managed code (i.e. .NET framework
> assembliues). Your "Declare" statements should be all you need to
> utilize the DLL from .NET.
>
> Have you tried loading the VB6 project using VS2005 and let the upgrade
> wizard convert your code?
>
> --
> Patrick Steele (patrick@mvps.org)
>
http://weblogs.asp.net/psteele
In article <A0A41FD7-BDA9-499E-AF5A-3064A79BE000@microsoft.com>,
steve@discussions.microsoft.com says...
[quoted text, click to view] > this is the function in the dll
> in vb.net I've made a module where i put the functions in.
> Declare Function csp2Init Lib "csp2.dll" (ByVal nComPort As Long) As Long
Did you run this through the VB.NET upgrade wizard?
According to your original post (the VB6 code), the datatypes above are
Long (4-bytes in VB6). In VB.NET, a 4-byte datatype is an Integer. So
the comparable translation of the above Declare in VB.NET would be:
Declare Function csp2Init _
Lib "csp2.dll" (ByVal nComPort As Integer) As Integer
I would have thought the conversion wizard and switched those for you.
--
Patrick Steele (patrick@mvps.org)