How To: Capture Desktop Screen with VB.NET

Capture Desktop Screen with VB.NET

Hello there. Today I wanna share on how to create a screen capture program.

Requirement:

  1. VB.NET
  2. PictureBox
  3. 2 Buttons ( Save, Capture)
  4. Monitor to see what u are doing ....

Create a Windows Form ....
Drag a Picture Box Onto The Form
Drag 2 Buttons Unto The Form
NAMELY: Capture and Save

Code for Capture:
------------------------------------------------------------------------
Dim bounds As Rectangle
Dim screenshot As System.Drawing.Bitmap
Dim graph As Graphics
bounds = Screen.PrimaryScreen.Bounds
screenshot = New System.Drawing.Bitmap(bounds.Width, bounds.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb)
graph = Graphics.FromImage(screenshot)
graph.CopyFromScreen(bounds.X, bounds.Y, 0, 0, bounds.Size, CopyPixelOperation.SourceCopy)
PictureBox1.Image = screenshot

Code for Save
------------------------------------------------------------------------
Dim sfd As New SaveFileDialog
If sfd.ShowDialog = Windows.Forms.DialogResult.OK Then
PictureBox1.Image.Save(sfd.FileName.ToString)
End If

And Thats it .....

Please FEEL Free to comment if u have any problem or u spot an error

Want to master Microsoft Excel and take your work-from-home job prospects to the next level? Jump-start your career with our Premium A-to-Z Microsoft Excel Training Bundle from the new Gadget Hacks Shop and get lifetime access to more than 40 hours of Basic to Advanced instruction on functions, formula, tools, and more.

Buy Now (97% off) >

Our Best Phone Hacks

Gadget Hacks' tips — delivered daily.

Be the First to Comment

Share Your Thoughts

  • Hot
  • Latest