如何在vb.net中使用twain获取设备名称? [英] how to get device name using twain in vb.net?

查看:192
本文介绍了如何在vb.net中使用twain获取设备名称?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在vb.net中使用twain获取设备名称她是我的代码,但它不起作用.....

  Dim  N 作为  
Dim i 作为

N = AxTwain1 .DeviceCount
如果 N> 0 然后
ComboBox1.Items.Clear()
For i = 1 N
' 注意使用索引属性的get_前缀DeviceName
ComboBox1.Items.Add(AxTwain1.get_DeviceName(i) - 1 ))
下一步
ComboBox1.SelectedIndex = 0


ComboBox1.Items.Add( 未找到TWAIN设备
ComboBox1.SelectedIndex = 0

结束 如果

解决方案

您的代码不正确。首先,如果N> 0,索引i应该从0开始,而不是1.其次,你应该将ComboBox1.Items.Add(找不到TWAIN设备)移动到else子句。以下是我使用动态.NET TWAIN SDK 更改代码逻辑的方法[ ^ ]:



 dynamicDotNetTwain.OpenSourceManager()
Dim N 正如
Dim i 正如

N = dynamicDotNetTwain.SourceCount
如果 N> 0 然后
ComboBox1.Items.Clear()
For i = 0 N
' 注意使用索引属性的get_前缀DeviceName
Name = dynamicDotNetTwain.SourceNameItems(Convert.ToInt16(i ))
ComboBox1.Items.Add(Name)
i + = 1
Next
其他
ComboBox1.Items.Add( 找不到TWAIN设备
结束 如果

ComboBox1.SelectedIndex = 0


how to get device name using twain in vb.net her is my code but its not working.....

Dim N As Long
        Dim i As Long

        N = AxTwain1.DeviceCount
        If N > 0 Then
            ComboBox1.Items.Clear()
            For i = 1 To N
                ' Note use of get_ prefix for indexed property DeviceName
                ComboBox1.Items.Add(AxTwain1.get_DeviceName(i - 1))
            Next
            ComboBox1.SelectedIndex = 0


            ComboBox1.Items.Add("No TWAIN devices found")
            ComboBox1.SelectedIndex = 0

        End If

解决方案

You code is incorrect. First, if N > 0, the index i should start from 0, not 1. Second, you should move ComboBox1.Items.Add("No TWAIN devices found") to else clause. Here is how I changed your code logic with Dynamic .NET TWAIN SDK[^]:

dynamicDotNetTwain.OpenSourceManager()
        Dim N As Long
        Dim i As Long

        N = dynamicDotNetTwain.SourceCount
        If N > 0 Then
            ComboBox1.Items.Clear()
            For i = 0 To N
                ' Note use of get_ prefix for indexed property DeviceName
                Name = dynamicDotNetTwain.SourceNameItems(Convert.ToInt16(i))
                ComboBox1.Items.Add(Name)
                i += 1
            Next
        Else
            ComboBox1.Items.Add("No TWAIN devices found")
        End If

        ComboBox1.SelectedIndex = 0


这篇关于如何在vb.net中使用twain获取设备名称?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆