CapRange 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_RANGE
TwainCap.CapInfo.Capability = L_ICAP_JPEGQUALITY
TwainCap.EnableMethodErrors = False

TwainCap.CapRange.RangeItemType = L_TWTY_INT16
CapVal.Type = VALUE_SHORT
CapVal.ShortValue = L_TWJQ_MEDIUM
TwainCap.CapRange.RangeCurrentValue = CapVal
CapVal.Type = VALUE_SHORT
CapVal.ShortValue = L_TWJQ_HIGH
TwainCap.CapRange.RangeDefaultValue = CapVal
CapVal.Type = VALUE_SHORT
CapVal.ShortValue = 0
TwainCap.CapRange.RangeMinimumValue = CapVal
CapVal.Type = VALUE_SHORT
CapVal.ShortValue = 50
TwainCap.CapRange.RangeMaximumValue = CapVal
CapVal.Type = VALUE_SHORT
CapVal.ShortValue = 10
TwainCap.CapRange.RangeStepSize = CapVal

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

Set TwainCap = Nothing