Code Examples

Visual Basic Examples

This page contains examples of communicating with FTDI devices through the D2XX drivers and FTD2XX.DLL using Visual Basic.

D2XX Module

many of the Visual Basic examples posted on this page use a module to interface to the D2XX DLL.  To download the unit (D2XX_Module.bas) for Visual Basic 6, click here.

Please note that the code examples below may already contain a module handling the D2XX DLL interface.  There may be differences between the current module file and the ones distributed with the examples.

Example 1

This application example was originally donated by Christian Vogt of Itec-technology and illustrates how to program the optional 93C46/93C56/93C66 EEPROM in VB6 using the latest D2XX driver release.  This enhanced version has restructured the program to use a separate unit to set up the DLL calls (module1.bas) which can then be re-used for developing other applications and has been updated to use the new EEPROM structure with FT2232C support.  The DLL version must be greater than 2.1.3.1 and the latest drivers must be installed for this example to work.

The code can be easily modified to work with the original FT_PROGRAM_DATA structure and older driver/DLL versions: simply remove the signature1, signature2 and version entries from the start of the structure and also remove the Rev 5 (FT2232C) entries from the bottom of the structure.

Implementing the FT_PROGRAM_DATA structure and the respective DLL-calls with VB6 has some “hooks”… The code uses another DLL, APIGID32.DLL, from DESAWARE Inc.  It is distributed with Dan Appleman’s book “Visual Basic Programmer’s Guide to the Win32 API”  – click here for info on this book.  Those of you who wish to use this code should consider purchasing this essential  book. 

This code is provided “as-is” for illustration purposes only and as such neither FTDI or Itec-technology provide technical support for this VB6 code or the APIGID32 DLL functionality.

To download the example, click here.

Example 2

Dan Kemppainen of IR Telemetrics has kindly donated a modified version of Christian Vogt’s original programming example.  This version does not require the 3rd party APIGID32 DLL  and is saved as a VB5 file.  This code is provided “as-is” for illustration purposes only and as such neither FTDI or IR Telemetrics provide technical support for this VB5 code.

To download the example, click here.

Example 3

This program returns device information on two devices connected at the same time.  Notice that there are two separate declarations for the different ways to use FT_ListDevices: one to get the number of devices currently attached and another to return a serial number or description string.  The sample gets the number of devices with FT_GetNumDevices() and then gets strings from each device in turn with FT_ListDevices(0,…) and FT_ListDevices(1,..).

Please note that this code is primarily intended to illustrate how to interface to the D2XX DLL in Visual Basic.  It’s functionality as a working application is limited to sending and receiving data from an FTDI UART device with a loop-back connector plugged into the RS232 port.

To download this example, click here.

Example 4

This example shows how to return device string information, open devices by description, set Baud rates, set flow control, set data characteristics, write string data to the device, read string data from the device and close the device.

This example was created using VB.NET and the module provided has many of the common calls to FTD2XX.DLL already set up with example functions.

To download this example, click here.

Example 5

This variant of FTDI’s D2XXAccess example for Windows CE uses VB.NET to list devices, return description strings, open devices, set Baud rates, read data and write data.  This example is also available in C# and C++ for Windows CE platforms.

This code requires that FTDI’s D2XX drivers for Windows CE be installed.  These can be obtained through our Drivers page.

To download the VB.NET version of D2XXAccess for Windows CE, click here.

Example 6

Our thanks go to Bob Freeth for providing this VB6 example of using the FT2232C MPSSE for SPI communication with a MAX187 ADC.

Source code and executable are available for free download.  This code is provided “as-is” for illustration purposes only and as such neither FTDI or Bob Freeth provide technical support for this VB6 code.