Ok, so in a part of my app i need the user to be able to specify a time to cound down form then when the time is hit. it fires an event. i have all that. the problem is i want to be able to see the time ticking down. right now it just stays the same.

this is what i have

private long ConvertSetTime(string theTime)
        {
            return TheTime(ref theTime);
        }

        private long TheTime(ref string theTime)
        {
            long seconds = 0;
            if (theTime.Trim().Substring(0, 1) == ":") // if leftmost colon, take it off
                theTime = theTime.Substring(1);
            string[] vals = theTime.Split(new char[] { ':', ' ', '.', '/' });
            for (int i = 0; i < vals.Length; i++)
            {
                seconds += Convert.ToInt32(vals[i]) * (long)Math.Pow((double)60, (double)(vals.Length - (1 + i)));
            }
            label2.Text = Convert.ToString(theTime);
            return seconds;
        }

        Font ClockFont = new Font("Times New Roman", 48, FontStyle.Bold);


        public string ConvertToTime(long tickCount)
        {
            // tickcount is in milliseconds, convert to minutes and seconds
            long seconds = tickCount;
            string val = (seconds / 60).ToString("00") + ":" + (seconds % 60).ToString("00");
            label2.Text = val;
            return val;
        }

        [DllImport("winmm.dll")]
        public static extern long PlaySound(String lpszName, IntPtr hModule, Int32 dwFlags);

then n the timer tick

StartTime--;
            Invalidate();
            if (StartTime == 0)
            {
                timer1.Stop();
                Invalidate();
                // Beep
                PlaySound("ringin.wav", (IntPtr)0, 0);
                PlaySound("ringin.wav", (IntPtr)0, 0);

            }

start button

if (StartTime > 0)
            {
                timer1.Start();
            }

p.s label2 is what shows the time on the form. the problem is i cant see it count down. How do i do this?

Hi
in your timertick

Invalidate();
            if (StartTime == 0)
            {
                timer1.Stop();
                Invalidate();
                // Beep
                PlaySound("ringin.wav", (IntPtr)0, 0);
                PlaySound("ringin.wav", (IntPtr)0, 0);

            }
ConvertToTime(StartTime)  //<- you forgot to put that in :)

also be sure that your timer has an interval of 1000

thx it worked

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.