Imports HR.EZTwainLibrary
Imports System.Runtime.InteropServices
Public Class frmNewScan
Private Sub btnSource_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSource.Click
If EZTwain.IsAvailable Then 'if TWain services are available
EZTwain.SelectTwainsource(Me.Handle) 'select Twain source
Exit Sub
Else
MsgBox("Twain not avaialble.", MsgBoxStyle.Critical)
End If
End Sub
Private Sub btnAcquire_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAcquire.Click
Dim Result As Integer
'Acquires a picture to a bitmap
With My.Computer.FileSystem
If .FileExists("C:\MyImage.Jpeg") Then
.DeleteFile("C:\MyImage.Jpeg")
End If
End With
Result = EZTwain.AcquireToFileName(Me.Handle, "C:\MyImage.Jpeg")
If Result = 0 Then 'if ok loads the image into the picturebox
PictureBox1.Image = Image.FromFile("C:\MyImage.Jpeg")
Exit Sub
Else
MsgBox("An error occured while scanning the picture.", MsgBoxStyle.Critical)
End If
End Sub
Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click
Dim pathfolder As String
pathfolder = "\" + Trim(Main.txtempno.Text)
Try
If txtFileName.Text = "" Then
MsgBox("Please Enter FileName of an Image.")
Else
Dim file_name As String = ("D:\pics" & pathfolder)
file_name = file_name.Substring(0, file_name.LastIndexOf("\")) & pathfolder & "\" & txtFileName.Text
Dim bm As Bitmap = PictureBox1.Image
' Save the picture as a JPEG
bm.Save(file_name & ".jpg", System.Drawing.Imaging.ImageFormat.Jpeg)
txtFileName.Text = ""
MsgBox("Ok")
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
hi,
I'm new in vb.net. Somebody help me about this problem. this problem occurs when i scan an images for the second time. i think the error is my filename(C:\MyImage.jpeg). how can i have a different filename thru coding or how to delete the tempory filename of an image to make scan again.
All replies are appreciated.
thanks for helping me.