Visual Basic Sample Program

The following Visual Basic example all that is required to do the following:

___________________________________________________________

Private Sub ExampleFunction()
    Dim SelectedSource As Long
    Dim RetVal As Long
    Dim ErrStatus As Long

    Rem Check for Twain
    if DTWAIN_IsTwainAvailable Then

        Rem Initialize DTWAIN
        DTWAIN_SysInitialize

        Rem open a TWAIN Source
        SelectedSource = DTWAIN_SelectSource

        if SelectedSource Then
        Rem Acquire to a BMP file
            RetVal = DTWAIN_AcquireFile(SelectedSource, "test.bmp", DTWAIN_BMP,_ 
                     DTWAIN_USENATIVE + DTWAIN_USENAME, DTWAIN_PT_DEFAULT, 1, 1, 1,_
                     ErrStatus)

        End If

        Rem Shut down DTWAIN
        DTWAIN_SysDestroy

    End If
EndSub

___________________________________________________________

That's all there is to it! The Visual Basic project just adds the DTWAIN32.BAS interface file to define the DTWAIN functions so that Visual Basic will recognize the functions such as DTWAIN_SysInitialize.

The documentation that comes with the DynaRithmic TWAIN Library discusses functions such as DTWAIN_AcquireFile in depth. It wasn't discussed here, but the goal of this small example is to show how simple it is to acquire images from a TWAIN device and save them to a file.

To acquire to the other file types other than BMP, the parameter that specifies DTWAIN_BMP can be any of the other file types such as DTWAIN_GIF, DTWAIN_JPEG, etc.. Therefore just 5 calls can save a file to any of many file types by just changing the third parameter to DTWAIN_AcquireFile

We will boldly challenge you to try to implement TWAIN image retrieval without DTWAIN, especially if you use Visual Basic. You will realize that you will save weeks of programming using DTWAIN than if you tried to implement this yourself.