Acquire multiple images from a scanner in VB

A sample application using TwainControlX

This example shows how to acquire a series of images from a TWAIN device, typically a scanner equipped with an Automatic Document Feeder (ADF).

To use this demo, you will need to download two files:

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

Zip file of VB demo project. (3kB)

Install TwainControlX, then extract the VB demo files from Open Visual Basic, and open the project TCX_Mult1.vbp.

The project consists of a single form, fMain. All the code is included in this form, there are no other modules. Run the project and click the Start button. A list of the TWAIN devices installed on your system will be displayed. Select one of the devices and up to 5 images will be captured and saved to disk as files "Image1.bmp" etc. The files will be saved in the default working directory for VB, so edit the code to specify a different path if you want to save them somewhere else.

VB Multiple Scan Demo

The user interface is disabled by the command 'Twain1.UseInterface = False'. The number of images to be acquired is set by the command 'Twain1.ImagesToRead = 5'. Either of these settings can be modified if required.

After each image is acquired, the code in 'Twain1_OnAcquire' will run. This saves the image to disk and displays it in a PictureBox.

Default settings for the image size and resolution will be used. This usually means that the image is too big to display in the PictureBox, so only the top left portion of the image will be seen on screen. The whole image will be saved to file.

Scanning will stop either when 5 images have been read, or when the ADF is empty.