Thank you. This worked great…
Thank you. This worked great in my VB.net 2019 application.
I added Me.Hide( ) before the grab, and Me.Show ( ) after the grab in order to hide my application (the other windows were the important stuff).
On Error GoTo err Dim shot As Size = New Size(My.Computer.Screen.Bounds.Width, My.Computer.Screen.Bounds.Height) Dim grab As New Bitmap(My.Computer.Screen.Bounds.Width, My.Computer.Screen.Bounds.Height) Dim s As System.Drawing.Graphics = System.Drawing.Graphics.FromImage(grab) s.CopyFromScreen(New Point(0, 0), New Point(0, 0), shot) grab.Save("screenshot.jpg") err: MsgBox("sorry unable to snap your screen and save at the moment please try again later", MsgBoxStyle.Critical, "Warning!") End Sub
On Error GoTo err
- this was the syntax that i had lectured a day ago. This syntax is for error handling that it will go to the variable err which will display "sorry unable to snap your screen and save at the moment please try again later".
Dim shot As Size = New Size(My.Computer.Screen.Bounds.Width, My.Computer.Screen.Bounds.Height)
- this syntax initializes shot as the size of your computer screen. Last day I discussed about My namespace that it provides information regarding your computer.
Dim grab As New Bitmap(My.Computer.Screen.Bounds.Width, My.Computer.Screen.Bounds.Height)
- this syntax initializes to create an image that corresponds to the size of your screen that will pass through the variable grab.
Dim s As System.Drawing.Graphics = System.Drawing.Graphics.FromImage(grab)
- this syntax holds the image that we create using the variable 'grab'. This syntax also has the Graphics to be passed through the variable 's'.
s.CopyFromScreen(New Point(0, 0), New Point(0, 0), shot) grab.Save("screenshot.jpg")
Engr. Lyndon R. Bermoy
IT Instructor/System Developer/Android Developer
Mobile: 09079373999
Telephone: 826-9296
E-mail:[email protected]
Visit and like my page on Facebook at: Bermz ISware Solutions
Subscribe at my YouTube Channel at: SerBermz