|
-
Oct 28th, 2009, 12:52 PM
#1
Thread Starter
Junior Member
[RESOLVED] Timer problem
This code countdown from 10 seconds to 0 second,then capture image and save to the specific folder,and than countdown to -1,-2,-3 etc,but I don't wont thet count to -1,-2,-3 etc...
I would like to do that when it comes to 0 seconds,that the timer countdown again from 10 second countdown to 0 and overvrite the image
Can somebody explain me how to do it?Thanks for any help
this is code
Code:
Public Class Form1
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Dim SC As String = 0
Label1.Text -= SC + 1
If Label1.Text = 0 Then
End If
If Label1.Text = 0 Then
Try
Dim scr As Size = New Size(My.Computer.Screen.Bounds.Width, My.Computer.Screen.Bounds.Height)
Dim screenGrab As New Bitmap(My.Computer.Screen.Bounds.Width, My.Computer.Screen.Bounds.Height)
Dim G As System.Drawing.Graphics = System.Drawing.Graphics.FromImage(screenGrab)
G.CopyFromScreen(New Point(0, 0), New Point(0, 0), scr)
screenGrab.Save("C:\test.jpeg")
Catch ex As Exception
End Try
End If
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Label1.Enabled = True
Timer1.Start()
End Sub
Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label1.Click
Label1.Enabled = False
End Sub
End Class
-
Oct 28th, 2009, 09:16 PM
#2
Re: Timer problem
Please turn option strict on first and fix all of the issues.
When you take the screenshot, why not just set the label value back to 10, so it basically starts over after the screenshot is taken.
-
Oct 29th, 2009, 03:11 AM
#3
Thread Starter
Junior Member
Re: Timer problem
 Originally Posted by Negative0
When you take the screenshot, why not just set the label value back to 10, so it basically starts over after the screenshot is taken.
Thaks for repay How should I set the value back to 10 after the screenshot is taken?
 Originally Posted by Negative0
Please turn option strict
I am a beginer in vb net and I like to know what do you mean with "turn option strict"
Thanks again
I found this what do you mean an I tun on this option.
Last edited by tony013; Oct 29th, 2009 at 03:33 AM.
-
Oct 29th, 2009, 09:05 AM
#4
Re: Timer problem
Option strict will dissallow implicit conversions, for one thing. This line, for instance, implicitly converts a number to a string:
Label1.Text -= SC + 1
It will work, but it is quite inefficient. Other implicit conversions, especially where you are working with strings and the + operator, may do something totally different from what you expect (because + can either concatenate two strings, or add two numbers, so you are hoping that it chooses what you want). Therefore, option strict will prevent some subtle bugs, as well as making the code run faster (though in this case you won't notice it).
You can set Option Strict ON by going to the Compile tab on Project|Properties. Once you do this, you will get LOTS of errors in your code. Kind of a pain, but now is the time to learn good habits, and this is a VERY good habit.
My usual boring signature: Nothing
 
-
Nov 2nd, 2009, 01:35 AM
#5
Addicted Member
Re: Timer problem
Try this:
Code:
Try
Dim scr As Size = New Size(My.Computer.Screen.Bounds.Width, My.Computer.Screen.Bounds.Height)
Dim screenGrab As New Bitmap(My.Computer.Screen.Bounds.Width, My.Computer.Screen.Bounds.Height)
Dim G As System.Drawing.Graphics = System.Drawing.Graphics.FromImage(screenGrab)
G.CopyFromScreen(New Point(0, 0), New Point(0, 0), scr)
screenGrab.Save("C:\test.jpeg")
Me.Label1.Text = 10
Catch ex As Exception
End Try
-
Nov 2nd, 2009, 04:13 AM
#6
Thread Starter
Junior Member
Re: Timer problem
Thanks,this is working good.Thanks again for help
-
Nov 2nd, 2009, 04:36 AM
#7
Hyperactive Member
Re: Timer problem
 Originally Posted by Shaggy Hiker
Once you do this, you will get LOTS of errors in your code. Kind of a pain, but now is the time to learn good habits, and this is a VERY good habit.
Nothing like the pain of trying to hunt down that very elusive bug. Learn to do it now. Some kinds of pain you can get over. Others will haunt you for life.
Last edited by AsmIscool; Nov 2nd, 2009 at 04:41 AM.
Slower than a crippled Vista
More buggy than a fresh XP install
Look! Down the road, some 50 miles behind the drunken snail.
It's Ubuntu!
-
Nov 2nd, 2009, 08:57 AM
#8
Thread Starter
Junior Member
Re: Timer problem
 Originally Posted by AsmIscool
Nothing like the pain of trying to hunt down that very elusive bug. Learn to do it now. Some kinds of pain you can get over. Others will haunt you for life.
Thaks for advice
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|