Hi to all,

I am developing asp.net website using VB.
In my website user registerd to access facilities but I want to give that authority for 1 month only. after 1 month user has to renew his account.
I am inserting date when he registerd in our site.
But the problem is how to find one month later date..?
let us consider one user is registerd on 12/8/2009 & I want to give message that your status will be inactive on 12/9/2009.

How to do that..?
Plz help!

Hi There

You can try this code
Note : RegisterDate is your actual date from table

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

          If CheckIsValidUser() = False Then
            Label1.Text = "Your Status is INACTIVE"
        Else
            Label1.Text = "Your Status is ACTIVE"
        End If
    End Sub

Private Function CheckIsValidUser() As Boolean
        '
        Dim RegisterDate As Date = Microsoft.VisualBasic.DateAdd(DateInterval.Month, -1, Date.Today).ToString
        Dim ExpiryDate As String = Microsoft.VisualBasic.DateAdd(DateInterval.Month, 1, RegisterDate).ToString
        If ExpiryDate.ToString = Date.Today.ToString Then
            ''Raise your exception
            Return False
        Else
            Return True
        End If



    End Function

Mark as solved if it helps you!!!

Thanks

try this this would work-

DateTime validTillDate = registrationDate.AddMonths(1);
        if (DateTime.Compare(DateTime.Now, validTillDate) < 0)
        {
            //Active
        }
        else
        {
            //Inactive
        }
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.