Divide by zero error
Posted: Thu Jan 14, 2010 3:37 am
I finally figured out what I was doing wrong and now it is saving multiple pages properly. Every one and awhile though, the user gets a divide by zero error, they exit the program, log back in and it works fine. Later just out of the blue, after working for a while it happens again. Here is the code.
if (vsTwain1.FeederLoaded)
{
vsTwain1.ShowIndicators = true;
while (vsTwain1.AcquireModal())
{
try
{
pictureBox1.Image = vsTwain1.GetCurrentImage();
vsTwain1.SaveImage(0, dirPath + filePath);
}
catch (TwainException ex)
{
if (vsTwain1.ErrorCode != Vintasoft.Twain.ErrorCode.None)
MessageBox.Show(vsTwain1.ErrorString);
else
MessageBox.Show(ex.Message);
}
}
myController.SaveScannedRecord(Int32.Parse(rdType.ToString()), filePath, DescriptionTextBox.Text.ToString(), numOfPages);
vsTwain1.StopDevice();
MessageBox.Show("Scan completed.");
}
if (vsTwain1.FeederLoaded)
{
vsTwain1.ShowIndicators = true;
while (vsTwain1.AcquireModal())
{
try
{
pictureBox1.Image = vsTwain1.GetCurrentImage();
vsTwain1.SaveImage(0, dirPath + filePath);
}
catch (TwainException ex)
{
if (vsTwain1.ErrorCode != Vintasoft.Twain.ErrorCode.None)
MessageBox.Show(vsTwain1.ErrorString);
else
MessageBox.Show(ex.Message);
}
}
myController.SaveScannedRecord(Int32.Parse(rdType.ToString()), filePath, DescriptionTextBox.Text.ToString(), numOfPages);
vsTwain1.StopDevice();
MessageBox.Show("Scan completed.");
}