Click here to Skip to main content
15,886,199 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello, I'm new to Vb.net and I have a problem with regards to my project
here's a sample code
VB
Private Sub MinsToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MinsToolStripMenuItem.Click
        Dim b As Boolean
        MsgBox(" pop up will return on " & Now.AddMinutes(5))

        Dim a = Now.AddMinutes(5)
        Try
            b = System.Convert.ToBoolean(a)

        Catch exception As System.InvalidCastException
            If a = True Then
                PopupNotifier1.Popup()

            End If
        End Try
    End Sub

what i want is that when i click the ToolStripMenuItem, it will wait for five minutes and then popnotifier1 will popup...

any help will be appreciated...
Posted
Updated 9-Jan-13 19:39pm
v6
Comments
Sergey Alexandrovich Kryukov 9-Jan-13 22:30pm    
It it System.Windows.Forms application? If so, tag "Forms". Always tag your UI library with a UI question...
—SA

First of all, "System.Convert.ToBoolean(a)" is not just bad or wrong, this is gibberish. What did you try to express with that?!

To pop up anything all of a sudden, after a certain time is a bad thing.
If you really think you need to do this bad thing (who knows why? so, maybe…), you should know: this one of really rare cases when you can use the really, really bad, and hence almost never used in quality software, timer System.Window.Forms.Timer: http://msdn.microsoft.com/en-us/library/system.windows.forms.timer.aspx[^].

The timer is bad due to poorest possible accuracy, so if it's good for something at all, this is your problem, where good accuracy is not needed. But this one is highly simplified in use. Read the help page referenced above; and you will see how to use it.

Other three (or so) timer classes available in .NET FCL are much better, but they all require at least minimal programming literacy to use, such as UI thread invocation, Dispatcher and the like.

—SA
 
Share this answer
 
why don you use javascript setTimeout function.. its rather more easier.. try it
 
Share this answer
 
I got it...

I just used thread.sleep and it worked!!!!
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900