Click here to Skip to main content
14,936,036 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
VB
Dim CD As New WIA.CommonDialog
Dim F As WIA.ImageFile =  CD.ShowAcquireImage(WIA.WiaDeviceType.ScannerDeviceType)

If IO.Directory.Exists(My.Application.Info.DirectoryPath + "\tmpimg") = False Then
   IO.Directory.CreateDirectory(My.Application.Info.DirectoryPath + "\tmpimg")
End If

Dim pic As New powerImage 'PictureBox
Dim sFile As String

sFile = "tmp" + New Random().Next.ToString + ".jpg"
F.SaveFile(My.Application.Info.DirectoryPath + "\tmpimg\" + sFile) ' αποθηκευω την εικονα

pic.Image = New Bitmap(My.Application.Info.DirectoryPath + "\tmpimg\" + sFile, False)
pic.Width = fpanelImages.Width - 25
pic.Height = pic.Width + (0.7 * pic.Width)

fpanelImages.Controls.Add(pic)
Posted
Updated 3-May-21 16:58pm
v2
Comments
fjdiewornncalwe 30-Jan-12 15:48pm
   
Is there a question you wish to ask, or is this meant as a tip/trick. If the latter is the situation, you should use the Post a Tip or Trick instead of what you used.
Sergey Alexandrovich Kryukov 30-Jan-12 16:17pm
   
I do not recommend such post, too. If it's going to be as unclear as this post, what's the use?
--SA
fountarlis 30-Jan-12 17:51pm
   
Ι΄m sorry ! This is a litle code where i use. Yes is a question and i looking to find how to work if the scaner device has autosystem for scan.
Sergey Alexandrovich Kryukov 30-Jan-12 16:16pm
   
Not a question. Not clear. What are those "pages", "images", etc. Why?
--SA
ZurdoDev 30-Jan-12 16:42pm
   
Based on the question in the title, just put your code in a loop. Ask the user if they want to scan more and then do it again and again. If your code is working putting it into a loop should be easy.

WIA does not support features of some scanners like autoscanning. I expect you will find that you will be stuck with the most basic functionality available, unless you can tell the user to start an 'autoscan' mode where you write your own loop, as someone suggested.
   
It's working
You need to add the Reference (Microsoft Windows Image Acquisition Library) or WIA.
in the code replace powerImage to PIctureBox
that's it
I hope it will work for you
Public Shared Function ScanDocs() As Image
        Dim CD As New WIA.CommonDialog
        Dim F As WIA.ImageFile = CD.ShowAcquireImage(WIA.WiaDeviceType.ScannerDeviceType)
' set your own folder
        Dim strTempfile = "Your Folder Here" & Format(Now, "MMddyyyyhhmmssms") & (1000 * Rnd()).ToString & ".tmp"
        Dim pic As New PictureBox

        F.SaveFile(strTempfile)
        pic.Image = New Bitmap(strTempfile)
        Return pic.Image
    End Function
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900