Acquire an image using TWAIN and VB.NET

A sample application using TwainControlX

This example shows a simple VB.NET application to acquire an image from a TWAIN device (scanner or webcam) and display the image. The demo files are included with the installer for the trial version of TwainControlX, available here:

Trial version of the ActiveX control TwainControlX. (1.5MB)

After installing TwainControlX the demo is available from the Windows Start Menu. The demo consists of a single form as shown below:

VB.NET Simple TWAIN Demo

Some useful points to note when using this demo:

  1. The device to be used is selected from a ComboBox. This is populated with the names of all installed devices when the project is first run.
  2. VB.NET cannot directly recognise indexed properties of ActiveX controls, such as the DeviceName property of TwainControlX. To access such properties, prefix the name of the property with 'get_' or 'set_' as shown in Sub Form1_Load.
  3. A CheckBox can be used to choose whether or not to display the default user interface of the device.
  4. If the user interface is not to be displayed, the resolution, pixel type, and size of the image can be set by the user.
  5. Both 32-bit and 64-bit versions of TwainControlX are available. This demo project has the target platform set to 'Any CPU' and so should automatically select the correct version of the OCX file.
  6. The 'About' button displays information about TwainControlX. This can be used to confirm the version currently in use.
  7. Images saved using the 'Save Image' button will be saved in the working directory of the VB project. A full path to the file can be specified to save to any other location.

Note that the demo has been prepared using the 2010 version of VB. For a copy of the demo compatible with older versions of VB.NET download the following ZIP file:

Zip file of demo project for older VB.NET versions. (34kB)