I want to print a Panel content but the result it's not high quality, I faced the same issue when I try to save a PictureBox image but I solve it with this Img.Setresolution(300, 300)
now I want to increase the quality of the result in any way ( also I tried to take a screenshot then store it in an image and print it I get a small image !! )
i tried this but it doesn't work for me :
Private Sub PrintDocument1_PrintPage(sender As Object, e As Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
Dim tmpImg As New Bitmap(Panel1.Width, Panel1.Height)
Using g As Graphics = Graphics.FromImage(tmpImg)
g.CopyFromScreen(Panel1.PointToScreen(New Point(0, 0)), New Point(0, 0), New Size(Panel1.Width, Panel1.Height))
End Using
e.Graphics.DrawImage(tmpImg, 0, 0)
Dim aPS As New PageSetupDialog
aPS.Document = PrintDocument1
'Dim bm As New Bitmap(Panel1.Width, Panel1.Height)
'Panel1.DrawToBitmap(bm, New Rectangle(0, 0, Panel1.Width, Panel1.Height))
'e.Graphics.DrawImage(bm, 0, 0)
'Dim aPS As New PageSetupDialog
'aPS.Document = PrintDocument1
End Sub
Related
You may have seen this question on other forum but i still can't resolve this issue.
I manage to get the text overlay for few second but after that it disappears and display following image (it does not stop the program):
i have a code like this when i got above error:
Private Sub CAPTURAR(sender As Object, eventArgs As NewFrameEventArgs)
If ButtonVIDEO.BackColor = Color.Black Then 'if n ot recording......
BMP = DirectCast(eventArgs.Frame.Clone(), Bitmap) 'PONE LOS DATOS EN EL BITMAP
PictureBox1.Image = DirectCast(eventArgs.Frame.Clone(), Bitmap) 'PUT THE DATA IN THE BITMAP
BMP.Dispose()
'insert text overlay
If BMP IsNot Nothing Then
Dim g As Graphics = Graphics.FromImage(PictureBox1.Image)
g.DrawString(New String("new"), New Font("Arial", 16), Brushes.White, New Rectangle(10, 10, 200, 50))
g.Dispose()
End If
Else ' SI ESTAS GRABANDO...
BMP = DirectCast(eventArgs.Frame.Clone(), Bitmap) ' If YOU ARE RECORDING
PictureBox1.Image = DirectCast(eventArgs.Frame.Clone(), Bitmap) 'PRESENTS THEM AT THE PICTURE BOX
ESCRITOR.WriteVideoFrame(BMP) 'KEEP THEM IN THE MEMORY
End If
End Sub
The full code is here: AForge WebCam Recorder
Thanks in advance
-
14 Jan 2020: updated code and i got the overlay on the video perfectly:
Private Sub ButtonVIDEO_Click(sender As System.Object, e As System.EventArgs) Handles ButtonVIDEO.Click
If ButtonVIDEO.BackColor = Color.Black Then 'YOU ARE NOT RECORDING VIDEO
SaveFileDialog1.DefaultExt = ".avi" 'SAVE AS AVI FILE
If SaveFileDialog1.ShowDialog() = System.Windows.Forms.DialogResult.OK Then
Dim ANCHO As Integer = CAMARA.VideoResolution.FrameSize.Width 'DEFINE THE WIDTH OF THE PHOTOGRAPH
Dim ALTO As Integer = CAMARA.VideoResolution.FrameSize.Height 'DEFINE THE HIGH OF THE PHOTOGRAPH
'CREATE THE FILE FOR DATA WITH SAVED PARAMETERS
ESCRITOR.Open(SaveFileDialog1.FileName, ANCHO, ALTO, NumericUpDownFPS.Value, VideoCodec.Default, NumericUpDownBRT.Value * 1000)
ESCRITOR.WriteVideoFrame(BMP) 'START SAVING DATA
ButtonVIDEO.BackColor = Color.Red 'SO WE KNOW THAT HE'S RECORDING
End If
Else
ButtonVIDEO.BackColor = Color.Black 'YOU ARE RECORDING
ESCRITOR.Close() 'STOP SAVING DATA
End If
End Sub
Private Sub CAPTURAR(ByVal sender As Object, ByVal eventArgs As NewFrameEventArgs)
Me.Invoke(CType(Function()
If ButtonVIDEO.BackColor = Color.Black Then 'IF YOU ARE NOT RECORDING ......
BMP = DirectCast(eventArgs.Frame.Clone(), Bitmap) 'PUT THE DATA IN THE BITMAP
PictureBox1.Image = DirectCast(eventArgs.Frame.Clone(), Bitmap) 'PRESENTS THEM AT THE PICTURE BOX
'insert text overlay
Else 'IF YOU ARE RECORDING ...
Try
BMP = DirectCast(eventArgs.Frame.Clone(), Bitmap) 'PUT THE DATA IN THE BITMAP
PictureBox1.Image = DirectCast(eventArgs.Frame.Clone(), Bitmap) 'PRESENTS THEM AT THE PICTURE BOX
ESCRITOR.WriteVideoFrame(BMP) 'KEEP THEM IN THE MEMORY
Catch ex As Exception
End Try
End If
If BMP IsNot Nothing Then
Dim g As Graphics = Graphics.FromImage(PictureBox1.Image)
g.DrawString(New String("new"), New Font("Arial", 16), Brushes.White, New Rectangle(10, 10, 200, 50))
g.Dispose()
End If
Me.Invoke(CType(Function()
End Function, MethodInvoker))
GC.Collect()
End Function, MethodInvoker))
End Sub
I am new to VB.net, I am working on a project for deliver service. I am currently using a standard Data grid view connected to a dataset, datasource, table adapter to display the pending items received. However, I was wondering if someone could help me to have the same pending items display like the second image below:
Use VirtualMode and a DataGridViewImageColumn. Draw the image you want in CellValueNeeded:
Public Class Form1
'Add a DataGridView called DataGridView1 to the form
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles Me.Load
Dim dtb As New DataTable()
dtb.Columns.Add("Col1", GetType(String))
dtb.Columns.Add("Col2", GetType(Integer))
dtb.Rows.Add("AA", 123)
dtb.Rows.Add("CC", 234)
DataGridView1.VirtualMode = True
DataGridView1.AutoGenerateColumns = False
DataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells
DataGridView1.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCells
DataGridView1.Columns.Add(New DataGridViewImageColumn() With {.Name = "img"})
DataGridView1.DataSource = dtb
End Sub
Private Sub DataGridView1_CellValueNeeded(sender As Object, e As DataGridViewCellValueEventArgs) Handles DataGridView1.CellValueNeeded
If DataGridView1.Columns(e.ColumnIndex).Name = "img" AndAlso e.ColumnIndex >= 0 AndAlso e.ColumnIndex < DataGridView1.ColumnCount Then
Select Case e.RowIndex
Case 0 To DataGridView1.RowCount - 2
Dim drw As DataRow = DirectCast(DataGridView1.Rows(e.RowIndex).DataBoundItem, DataRowView).Row
Dim strCol1Value As String = CStr(drw("Col1"))
Dim intCol2Value As Integer = CInt(drw("Col2"))
Dim bmp As New Bitmap(100, 50)
Using gfx As Graphics = Graphics.FromImage(bmp)
Dim brs As Brush = New System.Drawing.Drawing2D.LinearGradientBrush(New Point(0, 0), New Point(100, 50), Color.Black, Color.LightGray)
gfx.FillRectangle(brs, New RectangleF(0, 0, bmp.Width, bmp.Height))
gfx.DrawString(strCol1Value, New Font("Arial", 12), Brushes.Red, New PointF(0, 0))
gfx.DrawString(intCol2Value.ToString, New Font("Arial", 12), Brushes.Yellow, New PointF(0, 25))
End Using
e.Value = bmp
Case DataGridView1.RowCount - 1
Dim bmp As New Bitmap(100, 50)
Using gfx As Graphics = Graphics.FromImage(bmp)
gfx.DrawString("NEW", New Font("Arial", 12), Brushes.Red, New PointF(0, 0))
End Using
e.Value = bmp
Case Else
End Select
End If
End Sub
End Class
i have a VSTO for powerpoint and want to resize images so they are the same size as the slide. a sample image i have is 1000x300 and the slide is 960x540. so this is the code i have:
_W=960
_H=540
Dim img As Image = System.Drawing.Bitmap.FromFile(file1)
OldRect = New RectangleF(233, 0, 533, 300) ' calculated values to crop left and right
NewRect = New RectangleF(0, 0, _W, _H)
Dim bmp As Bitmap = New Bitmap(img, _W, _H)
Dim g As Graphics = Graphics.FromImage(bmp)
g.InterpolationMode = Drawing2D.InterpolationMode.HighQualityBicubic
g.PixelOffsetMode = Drawing2D.PixelOffsetMode.HighQuality
g.CompositingQuality = Drawing2D.CompositingQuality.HighQuality
g.DrawImage(img, NewRect, OldRect, GraphicsUnit.Pixel)
img.Save(file2, Imaging.ImageFormat.Png)
but when i look at file2 it's the same 1000x300 file as the original. what am i missing here?
#plutonix; you're spot on. i was under the wrong impression that DrawImage would replace the image it was offered. but saving the bitmap the graphics object was created with produced the intended image.
bmp.Save(file2, Imaging.ImageFormat.Png)
works perfect. thanks!
The answer posted here is good but there is one major problem of quality that need to be addressed. In most cased you have to Crop Image and Maintain the Quality so in that regard, I have improved the crop feature of a sample and posted below is the link. This demo is in VB.NET but you can easily understand the concept and make adjustments.
http://www.mediafire.com/file/70rmlpcdjyxo8gc/ImageCroppingDemo_-_Maintain_Image_Quality.zip/file
CODES For Cropping (VB.NET)
Dim cropX As Integer
Dim cropY As Integer
Dim cropWidth As Integer
Dim cropHeight As Integer
Dim oCropX As Integer
Dim oCropY As Integer
Dim cropBitmap As Bitmap
Dim Loadedimage As Image
Public cropPen As Pen
Public cropPenSize As Integer = 1 '2
Public cropDashStyle As Drawing2D.DashStyle = Drawing2D.DashStyle.Solid
Public cropPenColor As Color = Color.Yellow
Private Sub crobPictureBox_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles crobPictureBox.MouseDown
Try
If e.Button = Windows.Forms.MouseButtons.Left Then
cropX = e.X
cropY = e.Y
cropPen = New Pen(cropPenColor, cropPenSize)
cropPen.DashStyle = DashStyle.DashDotDot
Cursor = Cursors.Cross
End If
crobPictureBox.Refresh()
Catch exc As Exception
End Try
End Sub
Dim tmppoint As Point
Private Sub crobPictureBox_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles crobPictureBox.MouseMove
Try
If crobPictureBox.Image Is Nothing Then Exit Sub
If e.Button = Windows.Forms.MouseButtons.Left Then
crobPictureBox.Refresh()
cropWidth = e.X - cropX
cropHeight = e.Y - cropY
crobPictureBox.CreateGraphics.DrawRectangle(cropPen, cropX, cropY, cropWidth, cropHeight)
End If
' GC.Collect()
Catch exc As Exception
If Err.Number = 5 Then Exit Sub
End Try
End Sub
Private Sub crobPictureBox_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles crobPictureBox.MouseUp
Try
Cursor = Cursors.Default
Try
If cropWidth < 1 Then
Exit Sub
End If
Dim smallWidthPercentage As Single = (cropWidth / crobPictureBox.Width) * 100
Dim smallHeightPercentage As Single = (cropHeight / crobPictureBox.Height) * 100
Dim smallXPercentage As Single = (cropX / crobPictureBox.Width) * 100
Dim smallYPercentage As Single = (cropY / crobPictureBox.Height) * 100
smallHeightPercentage += 10
smallYPercentage -= 10
Dim Widthdifference As Integer = Loadedimage.Width - crobPictureBox.Width
Dim HeightDifference As Integer = Loadedimage.Height - crobPictureBox.Height
Dim rect As Rectangle
rect = New Rectangle((smallXPercentage / 100) * Loadedimage.Width, (smallYPercentage / 100) * Loadedimage.Height, (smallWidthPercentage / 100) * Loadedimage.Width, (smallHeightPercentage / 100) * Loadedimage.Height)
Dim bit As Bitmap = New Bitmap(Loadedimage, Loadedimage.Width, Loadedimage.Height)
cropBitmap = New Bitmap(Loadedimage, (smallWidthPercentage / 100) * Loadedimage.Width, (smallHeightPercentage / 100) * Loadedimage.Height)
Dim g As Graphics = Graphics.FromImage(cropBitmap)
g.InterpolationMode = Drawing2D.InterpolationMode.HighQualityBicubic
g.PixelOffsetMode = Drawing2D.PixelOffsetMode.HighQuality
g.CompositingQuality = Drawing2D.CompositingQuality.HighQuality
g.DrawImage(bit, 0, 0, rect, GraphicsUnit.Pixel)
PreviewPictureBox.Image = cropBitmap
Catch exc As Exception
End Try
Catch exc As Exception
End Try
End Sub
I need to put some graphics in one section of a TableLayoutPanel.
I'm doing this by creating a PictureBox in one cell of the TLP.
Can't get two things to work:
1) The initial display is blank! Drawing appears only when you resize the form
2) The resize event doesn't fire equally when expanding the size as compared contracting.
Any suggestions to improve the above two problems would be great!
Here is my code. The form has a 2x2 TableLayoutPanel in it, and one cell of the TLP has a PictureBox in it. Both the TLP and the PictureBox are set to Fill Parent:
Imports System.Drawing.Drawing2D
Public Class Form1
Private g As Graphics
Dim n As Integer = 0
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Debug.Print(String.Format("{0}{0}Form1_Load at {1}", vbCrLf, Now()))
Me.SetDesktopLocation(800, 200)
End Sub
Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint
n += 1
Debug.Print(String.Format("MyBase.Paint: {0}", n))
DisplayMyStuff()
End Sub
Private Sub PictureBox1_Resize(sender As Object, e As EventArgs) Handles Pict ureBox1.Resize
n += 1
Debug.Print(String.Format("PictureBox1.Resize: {0} PictureBoxSize = {1} / {2}", n, PictureBox1.Width, PictureBox1.Height))
If g IsNot Nothing Then
g.Dispose()
End If
g = PictureBox1.CreateGraphics()
End Sub
Private Sub DisplayMyStuff()
Dim rect1 As Rectangle
Dim rect2 As Rectangle
Dim pt1 As New Point(50, 50)
Dim pt2 As New Point(100, 100)
Dim pt3 As New Point(150, 150)
Dim brR As New SolidBrush(Color.Red)
Dim linGradBr As New LinearGradientBrush(pt2, pt3, Color.Yellow, Color.Blue)
Dim pictBoxSize As Size
Dim sz As Size
Dim width, height As Integer
pictBoxSize = New Size(CType(PictureBox1.Size, Point))
width = CInt(pictBoxSize.Width / 2)
height = CInt(pictBoxSize.Height / 2)
sz = New Size(width, height)
n += 1
Debug.Print(String.Format("DisplayMyStuff: {0}, Half-Size = {1} / {2}", n, width, height))
g.Clear(Color.Bisque)
rect1 = New Rectangle(pt1, sz)
rect2 = New Rectangle(pt2, sz)
g.FillRectangle(brR, rect1)
g.FillRectangle(linGradBr, rect2)
brR.Dispose()
linGradBr.Dispose()
End Sub
End Class
Apparently, you are trying to draw to a picturebox (g = PictureBox1.CreateGraphics())
The reason stuff disappears is that when the size changes, or something passes over the window, the controls and form need to be repainted. This happens in the Paint event, so your code needs to do the drawing there. Unlike a PictureBox image, items drawn to a form or control are not persistent on their own, that is done by drawing in the Paint event.
This is essentially your DrawMyStuff procedure relocated to the Picbox's Paint event.
Private Sub PictureBox1_Paint(sender As Object,
e As PaintEventArgs) Handles PictureBox1.Paint
Dim pt1 As New Point(50, 50)
Dim pt2 As New Point(100, 100)
Dim pt3 As New Point(150, 150)
Dim sz As New Size(CInt(PictureBox1.Size.Width / 2),
CInt(PictureBox1.Size.Height / 2))
n += 1
Debug.Print(String.Format("DisplayMyStuff: {0},
Half-Size = {1} / {2}", n, sz.Width, sz.Height))
Dim rect1 As New Rectangle(New Point(50, 50), sz)
Dim rect2 As New Rectangle(New Point(100, 100), sz)
Using linGradBr As New LinearGradientBrush(pt2, pt3, Color.Yellow, Color.Blue)
e.Graphics.Clear(Color.Bisque)
e.Graphics.DrawRectangle(Pens.Black, rect1)
e.Graphics.DrawRectangle(Pens.Black, rect2)
e.Graphics.FillRectangle(Brushes.Red, rect1)
e.Graphics.FillRectangle(linGradBr, rect2)
End Using
End Sub
If you are actually trying to paint on the Form, then Grim's answer is the solution. There you respond to the Form Paint event. In either case, use the Graphics object provided by Windows as an EventArg.
Above, you are using the Graphics object for the PictureBox (via event args) so output is to the PictureBox.
Windows wont know you are drawing something in the Paint event, so you need to tell it that the image needs to be updated at certain times such as when the PictureBox is resized. In the resize event, add:
PictureBox1.Invalidate ' tell windows it needs to be redrawn
' or
PictureBox1.Refresh ' redraw now
Me.Refresh is a bit of overkill because the entire form likely does not need to be repainted.
As Hans Passant says. First get rid of;
Private g As Graphics
and the whole of the PictureBox1_Resize(...)... routine. Then change the following routines to be like so;
Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint
DisplayMyStuff(e.Graphics)
End Sub
and
Private Sub DisplayMyStuff(pGraphics As Graphics)
Dim pt1 As New Point(50, 50)
Dim pt2 As New Point(100, 100)
Dim pt3 As New Point(150, 150)
Dim pictBoxSize As New Size(CType(PictureBox1.Size, Point))
Dim width As Integer = CInt(pictBoxSize.Width / 2)
Dim height As Integer = CInt(pictBoxSize.Height / 2)
Dim sz As New Size(width, height)
pGraphics.Clear(Color.Bisque)
Dim rect1 As New Rectangle(pt1, sz)
Dim rect2 As New Rectangle(pt2, sz)
Using linGradBr As New LinearGradientBrush(pt2, pt3, Color.Yellow, Color.Blue)
pGraphics.FillRectangle(Brushes.Red, rect1)
pGraphics.FillRectangle(linGradBr, rect2)
End Using
End Sub
.. then test. Please report back to tell me that you've learned something!! Especially.. that you don't need to create a new red brush - all 'standard' colours are built in - and that using the graphics object properly leads to better, smoother displays.
The image can be anything. It can be jpg, png, anything.
Load it.
Crop it. Say removing first 100 pixels from the left.
Save to the same file
Use Graphics.DrawImage Method (Image, RectangleF, RectangleF, GraphicsUnit) method.
Dim fileName = "C:\file.jpg"
Dim CropRect As New Rectangle(100, 0, 100, 100)
Dim OriginalImage = Image.FromFile(fileName)
Dim CropImage = New Bitmap(CropRect.Width, CropRect.Height)
Using grp = Graphics.FromImage(CropImage)
grp.DrawImage(OriginalImage, New Rectangle(0, 0, CropRect.Width, CropRect.Height), CropRect, GraphicsUnit.Pixel)
OriginalImage.Dispose()
CropImage.Save(fileName)
End Using
Ref: Graphics.DrawImage and Image Cropping with Image Resizing Using VB.NET
private void btnCropImage_Click(object sender, EventArgs e)
{
OpenFileDialog dlg = new OpenFileDialog();
dlg.ShowDialog();
//check your filename or set constraint on fileopen dialog
//to open image files
string str = dlg.FileName;
//Load Image File to Image Class Object to make crop operation
Image img = System.Drawing.Bitmap.FromFile(str);
// Create rectangle for source image, what ever it's size.
GraphicsUnit units = GraphicsUnit.Pixel;
RectangleF srcRect = img.GetBounds(ref units);
// Create rectangle for displaying image - leaving 100 pixels from left saving image size.
RectangleF destRect = new RectangleF(100.0F, 0.0F, srcRect.Width - 100, srcRect.Height);
// Bitmap class object to which saves croped image
Bitmap bmp = new Bitmap((int)srcRect.Width - 100, (int)srcRect.Height);
// Draw image to screen.
Graphics grp = Graphics.FromImage(bmp);
grp.DrawImage(img, destRect, srcRect, units);
//save image to disk
bmp.Save("e:\\img.jpeg", System.Drawing.Imaging.ImageFormat.Jpeg);
//Clear memory for Unused Source Image
img.Dispose();
}
Hope this help you..
Region "Image Cropping"
Dim cropX As Integer
Dim cropY As Integer
Dim cropWidth As Integer
Dim cropHeight As Integer
Dim oCropX As Integer
Dim oCropY As Integer
Dim cropBitmap As Bitmap
Public cropPen As Pen
Public cropPenSize As Integer = 1 '2
Public cropDashStyle As Drawing2D.DashStyle = Drawing2D.DashStyle.Solid
Public cropPenColor As Color = Color.Yellow
Private Sub RotateBtn_Click(sender As System.Object, e As EventArgs) Handles RotateBtn.Click
' RotateImage(PreviewPictureBox.Image, offset:=, angle:=90)
crobPictureBox.Image.RotateFlip(RotateFlipType.Rotate270FlipNone)
'PreviewPictureBox.Image.RotateFlip(RotateFlipType.Rotate270FlipNone)
'(45, PreviewPictureBox.Image)
End Sub
Private Sub crobPictureBox_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles crobPictureBox.MouseDown
Try
If e.Button = Windows.Forms.MouseButtons.Left Then
cropX = e.X
cropY = e.Y
cropPen = New Pen(cropPenColor, cropPenSize)
cropPen.DashStyle = DashStyle.DashDotDot
Cursor = Cursors.Cross
End If
crobPictureBox.Refresh()
Catch exc As Exception
End Try
End Sub
Dim tmppoint As Point
Private Sub crobPictureBox_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles crobPictureBox.MouseMove
Try
If crobPictureBox.Image Is Nothing Then Exit Sub
If e.Button = Windows.Forms.MouseButtons.Left Then
crobPictureBox.Refresh()
cropWidth = e.X - cropX
cropHeight = e.Y - cropY
crobPictureBox.CreateGraphics.DrawRectangle(cropPen, cropX, cropY, cropWidth, cropHeight)
End If
' GC.Collect()
Catch exc As Exception
If Err.Number = 5 Then Exit Sub
End Try
End Sub
Private Sub crobPictureBox_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles crobPictureBox.MouseUp
Try
Cursor = Cursors.Default
Try
If cropWidth < 1 Then
Exit Sub
End If
Dim rect As Rectangle = New Rectangle(cropX, cropY, cropWidth, cropHeight)
Dim bit As Bitmap = New Bitmap(crobPictureBox.Image, crobPictureBox.Width, crobPictureBox.Height)
cropBitmap = New Bitmap(cropWidth, cropHeight)
Dim g As Graphics = Graphics.FromImage(cropBitmap)
g.InterpolationMode = Drawing2D.InterpolationMode.HighQualityBicubic
g.PixelOffsetMode = Drawing2D.PixelOffsetMode.HighQuality
g.CompositingQuality = Drawing2D.CompositingQuality.HighQuality
g.DrawImage(bit, 0, 0, rect, GraphicsUnit.Pixel)
' g.DrawImage(bit, 0, 0, rect,GraphicsUnit.Pixel)
PreviewPictureBox.Image = cropBitmap
Catch exc As Exception
End Try
Catch exc As Exception
End Try
End Sub