Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#2.0
please help me i am new to windows application in c#
Now i am create a text to speak alarm clock my code is
:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
 
namespace _2TryAlarmClock
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
DateTime alarmtime;
private void timer1_Tick(object sender, EventArgs e)
{
label3.Text = DateTime.Now.ToLongTimeString();
if(label3.Text.Equals(alarmtime.ToString("HH:mm:ss")))
{
MessageBox.Show("Correct");
}
else
{
MessageBox.Show("Un-Correct");
}
 
}
private void Form1_Load(object sender, EventArgs e)
{
 
}
 
private void alarmon()
{
DateTime dt = DateTime.Now;
int hour = Convert.ToInt32(comboBox1.Text);
int min = Convert.ToInt32(comboBox2.Text);
int sec = Convert.ToInt32(comboBox3.Text);
alarmtime = new DateTime(dt.Year, dt.Month, dt.Day,hour, min, sec);
timer1.Enabled = true;
}
private void cloudStartMenuButton1_Click(object sender, EventArgs e)
{
alarmon();
}
 
}
}
but my timer tick event if condition is always go to else part .......
please anyone tell me a solution
Posted 26-Jun-13 3:25am
Edited 26-Jun-13 3:36am
CPallini328.6K
v2

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

What about debugging your application? In such cases, the debugger is really the best tool for finding out what's wrong in the program behaviour.
By the way, why are you comparing two strings obtained using different formatting options?
  Permalink  
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 325
1 DamithSL 265
2 CPallini 235
3 Maciej Los 190
4 Sergey Alexandrovich Kryukov 189
0 OriginalGriff 5,455
1 DamithSL 4,422
2 Maciej Los 3,860
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,010


Advertise | Privacy | Mobile
Web03 | 2.8.141216.1 | Last Updated 26 Jun 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100