Guest User

timer

a guest
Jun 14th, 2016
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. namespace projekt
  2. {
  3. public partial class Programowanie : Form
  4. {
  5.  
  6. int godziny, minuty, sekundy, setne_sekundy = 0;
  7.  
  8. public Programowanie()
  9. {
  10. InitializeComponent();
  11. }
  12.  
  13. private void timer1_Tick(object sender, EventArgs e)
  14. {
  15.  
  16. label1.Text = godziny+":"+minuty+":"+sekundy+":" + setne_sekundy.ToString();
  17. setne_sekundy++;
  18. if (setne_sekundy>10)
  19. {
  20. sekundy++;
  21. setne_sekundy = 0;
  22. }
  23. else
  24. {
  25. setne_sekundy = 0;
  26. }
  27. if(sekundy>60)
  28. {
  29. minuty++;
  30. sekundy = 0;
  31. }
  32. if (minuty > 60)
  33. {
  34. godziny++;
  35. minuty = 0;
  36. }
  37. }
  38.  
  39.  
  40. private void button1_Click(object sender, EventArgs e)
  41. {
  42.  
  43. timer1.Start();
  44. }
  45.  
  46.  
  47. private void button2_Click(object sender, EventArgs e)
  48. {
  49. timer1.Stop();
  50. }
  51. }
  52. }
Advertisement
Add Comment
Please, Sign In to add comment