FindFastConfig Example for Visual Basic

Dim WithEvents RasterTwain As LEADRasterTwain_U

Private Sub RasterTwain_FastConfigEvent(ByVal pltResConfig As LTRASTERTWAINLib_U.ILTFastConfig_U)
   ' ... set your code here




   RasterTwain.StopFindFastConfig = False
End Sub

Private Sub TwainAcquire_Click()
	Dim nRet As Integer
	Dim str As String

	'Unlock Document support.
	'Note that this is a sample key, which will not work in your toolkit.
	Set RasterTwain = New LEADRasterTwain_U
	RasterTwain.InitSession hWnd
	RasterTwain.SelectSource
	RasterTwain.UnlockSupport L_SUPPORT_DOCUMENT, "TestKey"
	RasterTwain.EnableFastConfigEvent = True
	RasterTwain.UserFastConfigsCount = 2

	RasterTwain.UserFastConfigs(0).TransferMode = L_LTWAIN_FILE_MODE
	RasterTwain.UserFastConfigs(0).FileFormat = FILE_BMP
	RasterTwain.UserFastConfigs(0).BitsPerPixel = 1

	RasterTwain.UserFastConfigs(1).TransferMode = L_LTWAIN_FILE_MODE
	RasterTwain.UserFastConfigs(1).FileFormat = FILE_TIF
	RasterTwain.UserFastConfigs(1).BitsPerPixel = 1

	nRet = RasterTwain.FindFastConfig("c:\Twain", L_LTWAIN_SHOW_USER_INTERFACE, 1, 1)

	If nRet = 0 Then
		MsgBox "FindFastConfig method was successful"
		MsgBox "Result Scan Configs count = " + CStr(RasterTwain.FastConfigsResultCount)

		str = "Transfer Mode = " + CStr(RasterTwain.FastConfigsResult(0).TransferMode) + Chr(13) + _
			"File Format = " + CStr(RasterTwain.FastConfigsResult(0).FileFormat) + Chr(13) + _
			"Buffer Size = " + CStr(RasterTwain.FastConfigsResult(0).BufferSize) + Chr(13) + _
			"Required Time = " + CStr(RasterTwain.FastConfigsResult(0).RequiredTime)

		MsgBox str, vbOKOnly, "Result Scan Configurations..."

		str = "Transfer Mode = " + CStr(RasterTwain.BestFastConfig.TransferMode) + Chr(13) + _
			"File Format = " + CStr(RasterTwain.BestFastConfig.FileFormat) + Chr(13) + _
			"Buffer Size = " + CStr(RasterTwain.BestFastConfig.BufferSize) + Chr(13) + _
			"Required Time = " + CStr(RasterTwain.BestFastConfig.RequiredTime)

		MsgBox str, vbOKOnly, "Resulting Scan Configurations..."
	Else
		MsgBox "Error occurred in the FindFastConfig method!!!", vbOKOnly, "Error!!!"
	End If
End Sub