PLZ hELP ME IN.....DATE COMPARISON!


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 5 of 5

Thread: PLZ hELP ME IN.....DATE COMPARISON!

Hybrid View

  1. #1
    Join Date
    Feb 2007
    Posts
    6

    PLZ hELP ME IN.....DATE COMPARISON!


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

    Dim dt As New Date

    If dt.Day() <= 16 Then

    MsgBox("allow")

    ElseIf dt.Day() >= 17 Then
    MsgBox("disallow")

    Else
    Label1.Text = "error"
    End If

    Im the beginner for the asp.net .
    I would like to allow user to view the results before 16/mm/yyyy and disallow when the date is reached after 17/mm/yyyy.....
    but when i write this code in the page load.....all the msgbox i get is ("allow") althougt the date is reached after 17/mm/yyyy.....
    pls help me. to solve this problem.....!

  2. #2
    Join Date
    Nov 2003
    Location
    Portland, OR
    Posts
    8,387
    Well, first of all, you cannot display a MsgBox in ASP.NET. ASP.NET code runs on the Web server, so users of your site would not be able to see a MsgBox. Generally, you would use a Literal or some other control on the page to display a message to the user.

    You are creating a new variable of type Date, but I don't see where you assign a value to it. Which date do you want to compare to 16 or 17? Today's date? Or a date that's passed in from the Web page?
    Phil Weber
    http://www.philweber.com

    Please post questions to the forums, where others may benefit.
    I do not offer free assistance by e-mail. Thank you!

  3. #3
    Join Date
    Dec 2003
    Posts
    2,750
    Your Date variable has not been initialized. Instead try:

    dt.Now.Day
    Paul
    ~~~~
    Microsoft MVP (Visual Basic)

  4. #4
    Join Date
    Feb 2007
    Posts
    6
    thanks phil weber and pclement!

    i already solved my problem.

    But i still got 1 question as below:
    if msgbox can't use.....
    so what is the best way to prompt the message instead of using msgbox?

  5. #5
    Join Date
    Mar 2007
    Location
    India
    Posts
    3

    Thumbs up You can use a message box..

    Try out this one..
    if you are using a button to check your code try applying this..
    Since I am using C# the code goes like this
    in page load event
    Button1.OnClientClick = String.Format("return alert('your custom message')");

    now when you'll click on the button.. you'll see a message box..
    Have fun
    Happy coding...

Similar Threads

  1. JAVA Date Utility Tutorial
    By hemanthjava in forum Java
    Replies: 0
    Last Post: 07-05-2006, 11:08 PM
  2. C#: Date Comparison
    By rkbnair in forum .NET
    Replies: 1
    Last Post: 05-23-2005, 12:31 PM
  3. Date Comparison
    By jbricher in forum ASP.NET
    Replies: 2
    Last Post: 04-10-2005, 01:37 PM
  4. Date and Time comparison
    By rtwitty in forum VB Classic
    Replies: 4
    Last Post: 02-24-2005, 02:12 PM
  5. date comparison
    By sxy in forum VB Classic
    Replies: 7
    Last Post: 06-12-2002, 12:00 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center