Disabling a menu link automatically at a certain date/time

Hi, i have an application which allows people to sign-up, however i only want them to be able to sign-up within a certain time frame, so if i want sign-ups to end by march 1st (for exampl) how can i program that into the application so whoever has downloaded it and installed it, on 1st march the menu link button for sign-up becomes disabled to everyone who has the software.

Thanks....
LVL 1
james130cAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

David LeeCommented:
Hi, james130c.

You'll want something like this.
Private Sub Form_Load()
    If Date >= #3/1/2008# Then
        'Change mnuSignUp to the name of your menu item
        mnuSignUp.Enabled = False
    End If
End Sub

Open in new window

0
james130cAuthor Commented:
Ok trying this i get 2 errors which are:

'Date' is a type that cannot be used as an expression
'.' expected.

Are the 2 errors, thanks.
0
David LeeCommented:
I tested before posting and tdidn't run into any errors.  What version of Visual Basic are you using?
0
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

james130cAuthor Commented:
i am using visual basic express....
0
David LeeCommented:
Ok, that's the problem.  This zone is for questions about the pre .net versions of Visual Basic.  The zone for the .net versions of VB is here: http://www.experts-exchange.com/Programming/Languages/.NET/Visual_Basic.NET/

For .Net VB you'll want something like this:
Public Class Form1
 
    Public Sub New()
 
        ' This call is required by the Windows Form Designer.
        InitializeComponent()
 
        ' Add any initialization after the InitializeComponent() call.
        If Microsoft.VisualBasic.DateAndTime.Today >= #2/1/2008# Then
            'Change the object name on the following line as needed
            Sub1ToolStripMenuItem.Enabled = False
        End If
    End Sub
End Class

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
james130cAuthor Commented:
Ok thank you for pointing that out to me, the code you supplied above doesn't give me errors, however when testing with a date that has already gone i am still able to click the menu link and it brings up the sign-up form still. The only time i have been able to disable it is within visual basic setting enable to false. I don't know if there is something else in the above code i need or not should it work?
0
David LeeCommented:
I tested this before posting and it did disable the menu selection.  Can you post the code you're using?
0
james130cAuthor Commented:
Here is the code i am using, thanks.
        signup_frm.Show()
        ' This call is required by the Windows Form Designer.
        InitializeComponent()
 
        ' Add any initialization after the InitializeComponent() call.
        If Microsoft.VisualBasic.DateAndTime.Today >= #2/1/2008# Then
            'Change the object name on the following line as needed
            sffl_signup.Enabled = False
        End If

Open in new window

0
james130cAuthor Commented:
Hi, i managed to sort this out now thanks that code worked fine, however im having one slight problem. When it reaches the date i want it to be disabled i want to change the text of the menu.

For example it's currenty called ( Sign-up ) and it's february 10th 2008, i want the menu to become disabled on february 11th 2008 (and once it is disabled i want it to be named ( Sign-ups Closed )

Here is the code i have so far
Public Sub New()
        ' This call is required by the Windows Form Designer.
        InitializeComponent()
 
        ' Add any initialization after the InitializeComponent() call.
        If Microsoft.VisualBasic.DateAndTime.Today >= #2/11/2008# Then
            'Change the object name on the following line as needed.
            sffl_signup.Enabled = False
 
            'Change signup text to competition closed.
            If sffl_signup.Enabled = False Then
 
            End If
        End If
    End Sub

Open in new window

0
james130cAuthor Commented:
I believe i have answered my own question to the last bit here is how i did it.
Public Sub New()
        ' This call is required by the Windows Form Designer.
        InitializeComponent()
 
        ' Add any initialization after the InitializeComponent() call.
        If Microsoft.VisualBasic.DateAndTime.Today >= #2/11/2008# Then
            'Change the object name on the following line as needed.
            sffl_signup.Enabled = False
 
            'Change signup text when date is reached.
            If sffl_signup.Enabled = False Then
 
                'Change the text to.  
                sffl_signup.Text = "Sign-ups Closed"
            End If
        End If
    End Sub

Open in new window

0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.