-
[RESOLVED] Run Time
if (lblTime.Text == MyString) //format to "hh:mm tt"
{
MessageBox.Show("hoy AM");
return 0;
}
above code problem is that showing multiple messagebox, i tried already this program in VB6 message box shows only once, but in C#.net i didn't yet press the OK button but continuously appear,
i want only to appear the message box once when my time is equal the system time
tnx.
-
Re: Run Time
That code is only going to show one message. If you're seeing multiple messages then you must be executing that code multiple times.
-
Re: Run Time
I think you accedentally put the code in form Activate event handler.
-
Re: Run Time
nope what i mean it is executing many times, not once
did you try... i want once only
tnx for youe help
-
Re: Run Time
it must be in the timer event right?
because as i've said i already did this in VB6, now i'm trying to do it
in C#.Net and that is my problem...
-
Re: Run Time
As I said, the code you posted will only display a single message. If you are seeing multiple messages then you must be executing it multiple times. As you haven't posted any other code then we can't possibly know. If that code is in a Timer's Tick event handler then it will be executed every time the Timer Ticks, of course. If the expression in the If statement is True then the message will be displayed. If the expression is True on more than one occasion that the code is executed then more than one message will be displayed, of course. We have no idea where this code fits in with the rest of your app or what the values of lblTime.Text or MyString are, so we cannot possibly tell you exactly why you're getting more messages than you want. We don't have ESP.
-
Re: Run Time
The question is where you put the code and where you initialize this two object before you compare? If you initialize outside the the timer event it would be posible that you can see multiple message because this two object values still the same as the timer ticks. Try to change the value of the one object after this line ...MesageBox.Show........
-
Re: Run Time
already fixed this problem, just put a flag as boolean on the timer event
tnx nway...