Click to See Complete Forum and Search --> : [RESOLVED] Using VB6 dll in VB.Net 2005


alex723
September 8th, 2008, 04:49 PM
I have old working VB6 application which uses IOTSLPIB.DLL to communicate with external device. IOTSLPIB.DLL file is in Windows\system32 folder. The application has module IOTIEEE.bas which contains various function declarations such as
[code]Declare Function _
MakeDevice Lib "IOTSLPIB.DLL" _
(ByVal devHandle As Integer, ByVal name As String) As Integer[code]

This function is called from other modules as
[code]
iRet = MakeDevice(handle,name)
[code]
And everythig works OK.

Now I need to use the same DLL in VB.NET application. First I tried to add it as a reference but it does not allow with error msg that “ A reference to IOTSLPIB.DLL could not be added… Make sure that it is a valid assembly or COM component”. From similar forum messages I learned that such DLL is Windows DLL and not .NET assembly and supposed to be used in VB.net different way declaring dll functions. I thought this is what I have in my VB module but it does not work. I added IOTIEEE.VB module in my project, also placed 'IOTSLPIB.DLL' file into application’s BIN folder as somebody suggested. But when it calls

[code]iRet = MakeDevice(handle,name) [code]
I still get an error

Unable to load DLL 'IOTSLPIB.DLL': The specified module could not be found. (Exception from HRESULT: 0x8007007E)

Where is my mistake?

Thanks

burningslash12
September 9th, 2008, 12:14 AM
Hi! It seems to me that you are making a program for controlling instruments via GPIB because of the DLL that you are using.

I have the same problem before but with a different DLL IEEE_32M.DLL. I have a Function Declaration that works perfectly in Excel Visual Basic for Application, but it doesn't work in VB .NET

I was able to solve my problem by downloading a new header file containing function declaration that is compatible for VB .NET.

Just try to search for a new version of the Function Declaration or the DLL.

Hope this helps.

alex723
September 9th, 2008, 10:07 AM
You are right, burningslash12. This is a DLL for an older GPIB card. I have newer GPIB card and another DLL to support it, and new VB module which works OK. But for older hardware I can use only this DLL and these particular declared functions. So my question is more general how to implement existing Windows DLL and VB6 module with declared DLL functions in VB.net. There are DLL experts in this forum who hopefully could help me with a solution.

Thanks

burningslash12
September 10th, 2008, 08:35 AM
Hopefully the DLL experts can give us some advice regarding this matter. I'm also new to VB .NET. I'm used to Excel Visual Basic for Application.