Code:
Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, _
ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
Private Const VK_SNAPSHOT = &H2C
Private Function SaveScreen(ByVal theFile As String) As Boolean
On Error Resume Next
'To get the Entire Screen
Call keybd_event(VK_SNAPSHOT, 1, 0, 0)
'To get the Active Window
'Call keybd_event(VK_SNAPSHOT, 0, 0, 0)
SavePicture Clipboard.GetData(vbCFBitmap), theFile
SaveScreen = True
Exit Function
End Function
Usage
Call SaveScreen("C:\Windows\Desktop\screenshot1.bmp")
Than after you save the picture, you can use the LoadPicture function to load it into the Picturebox.
Code:
Picture1.Picture = LoadPicture("C:\Windows\Desktop\screenshot1.bmp")