FTDI dll

tigz

Member
Joined
May 21, 2003
Messages
21
Hi,

im at uni doing a project using the FTDI USB chip. It allows you to connect to it using a dll and control its logic pins.

I can connect to it fine in visual basic 6. But im trying to get it working in vb.net so i can start getting familiar with .net and vb.net does multi-threading.

Ive copied the code from vb6 directly to vb.net and it seemed to compile fine so im assuming there are no language differences. But when i try to use the code i get errors returned from the dll and it wont allow me to connect.

Is there anything i should be doing or is the dll just not compatible with .net - but i thought dlls were usable by any language?

ive attached my code that just opens and closes the connection to the FTDI chip for you to have a look at.

Has anyone got any electronic books on vb.net, advanced features such as API calls, dll imports, mutli-threading? my book doesnt cover it.

Many Thanks
 
The code as it didnt attach properly in the form:


Dll declarations
Private Declare Function FT_Open Lib "FTD2XX.DLL" (ByVal intDeviceNumber As Integer, ByRef lngHandle As Long) As Long
Private Declare Function FT_Close Lib "FTD2XX.DLL" (ByVal lngHandle As Long) As Long

Return codes
Const FT_OK = 0
Const FT_INVALID_HANDLE = 1
Const FT_DEVICE_NOT_FOUND = 2
Const FT_DEVICE_NOT_OPENED = 3
Const FT_IO_ERROR = 4
Const FT_INSUFFICIENT_RESOURCES = 5

Private Sub TestBtn_Click()
Dim lngHandle As Long

open the device
If FT_Open(0, lngHandle) <> FT_OK Then
msgbox "Open Failed"
Exit Sub
End If

close the device
If FT_Close(lngHandle) <> FT_OK Then
msgbox "Close Failed"
exit sub
End If
end sub
 
You may want to check the declare statements in VB.Net some of the data types have changed

i.e.
in VB6 Integer was 16 bits in .Net it is now 32 bits (a short is 16 bits)

a long was 32 but has changed to 64

try the following code instead
[VB]
Dll declarations
Private Declare Function FT_Open Lib "FTD2XX.DLL" (ByVal intDeviceNumber As short, ByRef lngHandle As Integer) As Integer
Private Declare Function FT_Close Lib "FTD2XX.DLL" (ByVal lngHandle As Integer) As Integer
[/VB]

btw - no promises, not tried the code (not even checked it compiles never mind runs)
 
that sounds like itll work actually, because i did get an invalid parameter error code returned at some point while i was testing the other day. Many Thanks. Ill let you know tomoz
 
Back
Top