CapEnum Example for Visual Basic

Dim RasterTwain As New LEADRasterTwain_U
Dim CapVal As New LEADRasterVariant_U
Dim TwainCap As New LEADTwainCapability_U
Dim iRet As Integer

RasterTwain.InitSession hWnd
RasterTwain.SelectSource

TwainCap.CapInfo.ConType = L_TWON_ENUMERATION
TwainCap.CapInfo.Capability = L_ICAP_UNITS
TwainCap.EnableMethodErrors = False

TwainCap.CapEnum.EnumNumOfItems = 2

CapVal.Type = VALUE_USHORT
CapVal.LongValue = L_TWUN_INCHES
TwainCap.CapEnum.EnumCapValue(0) = CapVal
CapVal.Type = VALUE_USHORT
CapVal.LongValue = L_TWUN_TWIPS
TwainCap.CapEnum.EnumCapValue(1) = CapVal

TwainCap.CapEnum.EnumCurrentIndex = 0
TwainCap.CapEnum.EnumDefaultIndex = 0
TwainCap.CapEnum.EnumItemType = L_TWTY_UINT16

iRet = RasterTwain.SetCapability2(TwainCap, L_LTWAIN_CAPABILITY_SET)
If (iRet <> 0) Then
	MsgBox "Error Setting Capability"
End If

Set TwainCap = Nothing