This project has moved. For the latest updates, please go here.

Multiple Scanning using Saraff.Twain

May 14, 2014 at 9:37 AM
In my form there 6 scannings... means 6 picturebox...
I want to scan 6 time with saraff.twain... this code is scan one photo for one picturebox.. how can I scan multiple different photos for different photoboxes...

Private Sub scanButton_Click(sender As System.Object, e As System.EventArgs) Handles scanButton.Click
    Try
        Me._twain32.Acquire()
    Catch ex As Exception
        MessageBox.Show(ex.Message, ex.GetType().Name, MessageBoxButtons.OK, MessageBoxIcon.Error)
    End Try
End Sub


Private Sub _twain32_AcquireCompleted1(sender As System.Object, e As System.EventArgs) Handles _twain32.AcquireCompleted
    Try
        If Not Me.Photopicturebox1.Image Is Nothing Then
            Me.Photopicturebox1.Image.Dispose()
        End If
        Me.Photopicturebox1.Image = Me._twain32.GetImage(0)
        Me.Photopicturebox1.Visible = True
    Catch ex As Exception
        MessageBox.Show(ex.Message, ex.GetType().Name, MessageBoxButtons.OK, MessageBoxIcon.Error)
    End Try
End Sub
Coordinator
May 14, 2014 at 11:35 AM
Hello, rajanpandit.
If I understand the question, it does not quite address. But try follow:
private PictureBox[] _boxes=new PictureBox[]{
    this.pictureBox1,
    this.pictureBox2,
    this.pictureBox3,
    this.pictureBox4,
    this.pictureBox5,
    this.pictureBox6
};
private int _index=0;

private void _SetImage(Image image) {
    if(this.pictureBox1.Image!=null) {
        this._index=++this._index%this._boxes.Length;
        if(this.Current!=null) {
            this.Current.Dispose();
        }
        this.Current=image;
    }
}

private Image Current {
    get {
        return this._boxes[this._index].Image;
    }
}
May 14, 2014 at 11:50 AM
Thanks but I am vb.net user... can u give me vb.net code.... plz
May 14, 2014 at 11:56 AM
and I explain my question briefly... I have six pictureboxes in a form and six different buttons which I want to use for scan... the code which I have taken from one of your example, scan in one picturebox only.... what modification can be done iin the the code so that I can use for each button....
Coordinator
May 14, 2014 at 12:46 PM
Hello, rajanpandit.
That yourself must to figure out how make the way you want it.