Results 1 to 8 of 8

Thread: [RESOLVED] Run Time

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2006
    Location
    /root/usr/local/bin
    Posts
    476

    Resolved [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.

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    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.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2006
    Location
    /root/usr/local/bin
    Posts
    476

    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

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2006
    Location
    /root/usr/local/bin
    Posts
    476

    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...

  6. #6
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    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.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  7. #7
    Fanatic Member popskie's Avatar
    Join Date
    Jul 2005
    Location
    In my chair
    Posts
    666

    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........

  8. #8

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2006
    Location
    /root/usr/local/bin
    Posts
    476

    Re: Run Time

    already fixed this problem, just put a flag as boolean on the timer event

    tnx nway...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width