如何使用visual basic express在visual basic.net中的下面的代碼修復此錯誤? 3循環後不支持異常未處理。 「PictureBox1.Image.Save(dtmTestX,System.Drawing.Imaging.ImageFormat.Jpeg)」visualbasic.net中的一般錯誤
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Dim dtmTest As Date
dtmTest = TimeValue(Now)
Dim bounds As Rectangle
Dim screenshot As System.Drawing.Bitmap
Dim graph As Graphics
Dim dtmTestSaveLocation As String
dtmTestSaveLocation = "D:\test" + dtmTest + ".jpg"
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
PictureBox1.Image.Save(dtmTestSaveLocation, System.Drawing.Imaging.ImageFormat.Jpeg)
End Sub
你得到的錯誤信息是什麼? – CedX 2012-01-09 20:59:21
重新標記。這不是VBA。 – HardCode 2012-01-09 21:07:22
文件名將包含從DateTime到字符串轉換的「:」字符。這不是文件名中的有效字符。 – 2012-01-09 21:37:28