VintaSoft Twain .NET SDK 15.4: Documentation for .NET developer
Vintasoft.Sane Namespace / SaneLocalDeviceOption Class / SetValue Methods / SetValue(Double) Method
Syntax Exceptions Example Requirements SeeAlso
In This Topic
SetValue(Double) Method (SaneLocalDeviceOption)
In This Topic
Set the fixed value of this SANE option.
Syntax
'Declaration

Public Overloads Sub SetValue( _
ByVal value
A fixed value.
As Double _
)
public void SetValue(
double value
)

Parameters

value
A fixed 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