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?

[Webinar] Streamline your web hosting managementRegister Today

x
 
David LeeConnect With a Mentor Commented:
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
 
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
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
David LeeCommented:
I tested before posting and tdidn't run into any errors.  What version of Visual Basic are you using?
0
 
james130cAuthor Commented:
i am using visual basic express....
0
 
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
All Courses

From novice to tech pro — start learning today.