validations in .NET

  • Thread starter Thread starter Newbie
  • Start date Start date
N

Newbie

Hi all,
I am using a date time picker control in my .net application.
Now I want to validate the values entered here. I want to calculate the
difference of start time and end time, but start time should not be more
than end time, or else it should display invalid entry.
Also, while calculating difference, i want to take into consideration the AM
and PM thing.
Please suggest.
TIA.
 
Hi

You can use the DateDiff Function to calculate the difference in times.

To determine in the Start Date is after the End Date you could try somethin
like this.

Dim StartDate As Date
Dim EndDate As Date

If StartDate > EndDate Then
' code here to tell user that Start Date is after End Date
Else
' code here if Dates are OK
End If

Hope this helps.

Neil Knobbe
Visual Basic MVP
 
* "Neil Knobbe said:
You can use the DateDiff Function to calculate the difference in times.

To determine in the Start Date is after the End Date you could try somethin
like this.

Dim StartDate As Date
Dim EndDate As Date

If StartDate > EndDate Then
' code here to tell user that Start Date is after End Date
Else
' code here if Dates are OK
End If

In addition, you can use an ErrorProvider to make the user aware of the
invalid input.
 
Hi Herfried,

I know I have once written something else, however can you keep the
crossposting to the dotnet groups valid.

A lot who are active here are that also in dotnet.general and
dotnet.framework.adonet and aspnet.

Thanks.

Cor
 
* "Cor Ligthert said:
I know I have once written something else, however can you keep the
crossposting to the dotnet groups valid.

A lot who are active here are that also in dotnet.general and
dotnet.framework.adonet and aspnet.

My newsreader doesn't support posting to groups I am not subsrcibed to.
 
Back
Top