VintaSoft Twain .NET SDK 15.3: Documentation for .NET developer
Vintasoft.Sane Namespace / SaneLocalDeviceOption Class / SetValue Methods / SetValue(Int32) Method
Syntax Exceptions Example Requirements SeeAlso
In This Topic
    SetValue(Int32) Method (SaneLocalDeviceOption)
    In This Topic
    Set the integer value of this SANE option.
    Syntax
    'Declaration
    
    Public Overloads Sub SetValue( _
    ByVal value
    An integer value.
    As Integer _
    )
    public void SetValue(
    int value
    )
    public: void SetValue(
    int value
    )
    public:
    void SetValue(
    int value
    )

    Parameters

    value
    An integer value.
    Exceptions
    ExceptionDescription
    Thrown if device is not opened, option is not active or option has not supported value type.
    Example

    This C#/VB.NET code shows how to set value of SANE device option.

    
    ''' <summary>
    ''' Sets value of SANE device option.
    ''' </summary>
    Public Sub SetValueOfSaneDeviceOption()
        ' create SANE device manager
        Using deviceManager As New Vintasoft.Sane.SaneLocalDeviceManager()
            ' open SANE device manager
            deviceManager.Open()
    
            ' get count of SANE devices
            Dim deviceCount As Integer = deviceManager.Devices.Count
            If deviceCount = 0 Then
                System.Console.WriteLine("Devices are not found.")
                Return
            End If
    
            ' select the first SANE device
            Dim device As Vintasoft.Sane.SaneLocalDevice = deviceManager.Devices(0)
    
            ' open SANE device
            device.Open()
    
            System.Console.WriteLine("Device name: " + device.Name)
    
            ' get SANE device option with name "source"
            Dim sourceOption As Vintasoft.Sane.SaneLocalDeviceOption = device.Options.Find("source")
            ' if option is found
            If sourceOption IsNot Nothing Then
                ' set new value for option
                sourceOption.SetValue("Flatbed")
            End If
    
            ' close SANE device
            device.Close()
    
            ' close SANE device manager
            deviceManager.Close()
        End Using
    
        System.Console.ReadLine()
    End Sub
    
    
    
    /// <summary>
    /// Sets value of SANE device option.
    /// </summary>
    public void SetValueOfSaneDeviceOption()
    {
        // create SANE device manager
        using (Vintasoft.Sane.SaneLocalDeviceManager deviceManager = new Vintasoft.Sane.SaneLocalDeviceManager())
        {
            // open SANE device manager
            deviceManager.Open();
    
            // get count of SANE devices
            int deviceCount = deviceManager.Devices.Count;
            if (deviceCount == 0)
            {
                System.Console.WriteLine("Devices are not found.");
                return;
            }
    
            // select the first SANE device
            Vintasoft.Sane.SaneLocalDevice device = deviceManager.Devices[0];
    
            // open SANE device
            device.Open();
    
            System.Console.WriteLine("Device name: " + device.Name);
    
            // get SANE device option with name "source"
            Vintasoft.Sane.SaneLocalDeviceOption sourceOption = device.Options.Find("source");
            // if option is found
            if (sourceOption != null)
            {
                // set new value for option
                sourceOption.SetValue("Flatbed");
            }
    
            // close SANE device
            device.Close();
    
            // close SANE device manager
            deviceManager.Close();
        }
    
        System.Console.ReadLine();
    }
    
    

    Requirements

    Target Platforms: .NET 10; .NET 9; .NET 8; .NET 7; .NET 6

    See Also