hey i've created a counting mechanism project............in the attached project there is two labels label1 & label2.........on pressing the numberpad1 and numberpad3 keys, the count increments and decrements simultaneously which is been displayed in the corresponding labels (see the attached project)........

can anyone tell me an another method to do that by without using the timers..............

where do you use the timers?

for displaying the count within the label while pressing the keys...............

still, I dont understand your question.

what is it that you want to do without timers?

you could set bools indicating the state of the keys then have one timer that checks the bools and makes the changes.

when video-streaming is activated the counting seems to be a little delay.........since because i'm using timers

Anybody please help me

int iNum = 0;

        bool bLeft = false;
        bool bRight = false;

        public MainForm()
        {
            InitializeComponent();
        }
        private void MainFormKeyUp(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.NumPad3)
                bRight = false;
            if (e.KeyCode == Keys.NumPad1)
                bLeft = false;
        }

        private void MainFormKeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.NumPad3)
                bRight = true;
            if (e.KeyCode == Keys.NumPad1)
                bLeft = true;
        }

        private void timer1_Tick_1(object sender, EventArgs e)
        {
            if (bRight)
                iNum++;
            if (bLeft)
                iNum--;
            if (iNum > 0)
            {
                label1.Text = iNum.ToString();
                label2.Text = "0";
            }
            else
            {
                label1.Text = "0";
                label2.Text = Math.Abs(iNum).ToString();
            }
        }

that will make the numbers better but i can figure out what you are trying to do with the camera

that works fine with a single timer.........

but can u please tell me why the counting seems a bit delay in between when we activate the videocapturing(see the attached PROJCT.zip)..............

is there any solution for that................

anybody help me

hey how can i put a count limit of 30 in the above code..........

the counting is dealyed because the timer doesnt start right away after you set the timer.Enabled property to true. you have to call to it yourself the first time:

private void MainFormKeyUp(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.NumPad3)
            {
                bRight = false;
                timer1.Stop();
            }
            if (e.KeyCode == Keys.NumPad1)
            {
                bLeft = false;
                timer1.Stop();
            }
        }

        private void MainFormKeyDown(object sender, KeyEventArgs e)
        {

            if (bRight || bLeft) return;

            if (e.KeyCode == Keys.NumPad3)
            {
                bRight = true;
                timer1.Start();
                ProcessTick();
            }
            if (e.KeyCode == Keys.NumPad1)
            {
                bLeft = true;
                timer1.Start();
                ProcessTick();
            }            
        }
        private void timer1_Tick(object sender, EventArgs e)
        {
            ProcessTick();
        }

        void ProcessTick() 
        {
            timer1.Interval = (200);

            if (bRight)
                iNum++;
            if (bLeft)
                iNum--;
            if (iNum > 0)
            {
                label1.Text = iNum.ToString();
                label2.Text = "0";
            }
            else
            {
                label1.Text = "0";
                label2.Text = Math.Abs(iNum).ToString();
            }
            //timer1.Enabled = false;
        }
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.