7 Replies - 4069 Views - Last Post: 25 February 2010 - 03:10 AM Rate Topic: -----

#1 kanuri1  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 42
  • Joined: 04-January 10

dll file for comparing two text box dates

Posted 25 February 2010 - 12:01 AM

hi
iwant to create an dll file for comparing two text box dates,,
since in my project comparing dates is very necessry for every form,,so iwant to create an dll file,,
here iam created an dll file but it was not working,
here iam working with asp.net with vb.net.....
here my code os given below,,,
it was very urgent please help me,,,,,,,
Imports System
Imports Microsoft.VisualBasic

Namespace datecompare
    Public Class class1
        Public Function arr(ByVal a As String)
            Dim today As Date
            today = Date.Today
            If a.Trim <> "" Then
                If (DateTime.Compare(CType(a, Date), today) < 0) Then
                    MsgBox("The entered date should not be earlier than todays date!")
                    Return False
                End If
            End If
            Return a
        End Function

        Public Function dept(ByVal b As String, ByVal a As String)
            If a.Trim <> "" And b.Trim = "" Then
                If (DateTime.Compare(CType(b, Date), CType(a, Date)) < 0) Then
                    MsgBox("The entered date should not be earlier than Arrival date!")
                    Return False
                End If
            End If
            Return b
        End Function
    End Class
End Namespace


Is This A Good Question/Topic? 0
  • +

Replies To: dll file for comparing two text box dates

#2 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon


Reputation: 2271
  • View blog
  • Posts: 9,499
  • Joined: 29-May 08

Re: dll file for comparing two text box dates

Posted 25 February 2010 - 12:31 AM

First you do know that DLLs aren't magic ibjects that which automagically do things.
All they are Classes which contain you a invoke via an instance of that class.
Use them to create a library of methods you commonly use, to save you rewriting them each time.
Or to expend the capabilities of the language.

Secondly, start to step away from the vb6 libraries(Imports Microsoft.VisualBasic) and start to use the .net versions.

So if you are comparing date, then you need a date object.

Thirdly, Never Ever trust the user to enter the correct information.
Validate all user entries.

Eg. If expect the user to enter date, then check by trying to see if the string can be parsed as a date.
Convert the string to a date, doesn't check if the string is a date.
Was This Post Helpful? 0
  • +
  • -

#3 kanuri1  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 42
  • Joined: 04-January 10

Re: dll file for comparing two text box dates

Posted 25 February 2010 - 01:01 AM

View PostAdamSpeight2008, on 24 February 2010 - 11:31 PM, said:

First you do know that DLLs aren't magic ibjects that which automagically do things.
All they are Classes which contain you a invoke via an instance of that class.
Use them to create a library of methods you commonly use, to save you rewriting them each time.
Or to expend the capabilities of the language.

Secondly, start to step away from the vb6 libraries(Imports Microsoft.VisualBasic) and start to use the .net versions.

So if you are comparing date, then you need a date object.

Thirdly, Never Ever trust the user to enter the correct information.
Validate all user entries.

Eg. If expect the user to enter date, then check by trying to see if the string can be parsed as a date.
Convert the string to a date, doesn't check if the string is a date.


hi i understand what you say ,,,,i know dll file,,,,iam tried very much for comparing two text boxes dates,
so please give me code regarding mine.......
it was very help ful tome .please........
thnx.........
Was This Post Helpful? 0
  • +
  • -

#4 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon


Reputation: 2271
  • View blog
  • Posts: 9,499
  • Joined: 29-May 08

Re: dll file for comparing two text box dates

Posted 25 February 2010 - 01:11 AM

The main object you need is Date.
Was This Post Helpful? 0
  • +
  • -

#5 kanuri1  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 42
  • Joined: 04-January 10

Re: dll file for comparing two text box dates

Posted 25 February 2010 - 01:42 AM

View PostAdamSpeight2008, on 25 February 2010 - 12:11 AM, said:

The main object you need is Date.

hi thnax for your suggestion,,,,,,,
but when iam using the date object also nopt working
my coding is given below..........
Namespace datecompare
    Public Class class1
        Public Function arr(ByVal a As String)
            Dim today As Date
            today = Date.Today
            If a.Trim <> "" Then
                If (DateTime.Compare(CType(a, Date), today) < 0) Then
                    MsgBox("The entered date should not be earlier than todays date!")
                    Return False
                End If
            End If
            Return a
        End Function

        Public Function dept(ByVal b As Date, ByVal a As Date)
            If (DateTime.Compare(CType(b, Date), CType(a, Date)) < 0) Then
                MsgBox("The entered date should not be earlier than Arrival date!")
                Return False
            End If
            Return b
        End Function
    End Class
End Namespace

please try to correct the errors or give me the code...........

This post has been edited by kanuri1: 25 February 2010 - 01:43 AM

Was This Post Helpful? 0
  • +
  • -

#6 fixo  Icon User is offline

  • D.I.C Regular

Reputation: 85
  • View blog
  • Posts: 335
  • Joined: 10-May 09

Re: dll file for comparing two text box dates

Posted 25 February 2010 - 01:52 AM

View Postkanuri1, on 25 February 2010 - 12:01 AM, said:

View PostAdamSpeight2008, on 24 February 2010 - 11:31 PM, said:

First you do know that DLLs aren't magic ibjects that which automagically do things.
All they are Classes which contain you a invoke via an instance of that class.
Use them to create a library of methods you commonly use, to save you rewriting them each time.
Or to expend the capabilities of the language.

Secondly, start to step away from the vb6 libraries(Imports Microsoft.VisualBasic) and start to use the .net versions.

So if you are comparing date, then you need a date object.

Thirdly, Never Ever trust the user to enter the correct information.
Validate all user entries.

Eg. If expect the user to enter date, then check by trying to see if the string can be parsed as a date.
Convert the string to a date, doesn't check if the string is a date.


hi i understand what you say ,,,,i know dll file,,,,iam tried very much for comparing two text boxes dates,
so please give me code regarding mine.......
it was very help ful tome .please........
thnx.........

Take a look at the powerful 'TimeSpan' class
Here is a quick example
I have writing it from memory so
perhaps there are the mistakes in there:
        Dim date1 As Date = System.Date.Now

        Dim date2 As Date = "26/02/2010"

        'get the difference between two dates
        Dim diff As System.TimeSpan = date1 - date2
        'get the number of days (change on whatever you need - seconds, minutes etc)
        Dim days As Integer = diff.TotalDays
        'compare dates
        If (days < 0) Then
            MsgBox("The entered date should not be earlier than Arrival date!")
        End If



~'J'~
Was This Post Helpful? 0
  • +
  • -

#7 kanuri1  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 42
  • Joined: 04-January 10

Re: dll file for comparing two text box dates

Posted 25 February 2010 - 02:55 AM

View Postfixo, on 25 February 2010 - 12:52 AM, said:

View Postkanuri1, on 25 February 2010 - 12:01 AM, said:

View PostAdamSpeight2008, on 24 February 2010 - 11:31 PM, said:

First you do know that DLLs aren't magic ibjects that which automagically do things.
All they are Classes which contain you a invoke via an instance of that class.
Use them to create a library of methods you commonly use, to save you rewriting them each time.
Or to expend the capabilities of the language.

Secondly, start to step away from the vb6 libraries(Imports Microsoft.VisualBasic) and start to use the .net versions.

So if you are comparing date, then you need a date object.

Thirdly, Never Ever trust the user to enter the correct information.
Validate all user entries.

Eg. If expect the user to enter date, then check by trying to see if the string can be parsed as a date.
Convert the string to a date, doesn't check if the string is a date.


hi i understand what you say ,,,,i know dll file,,,,iam tried very much for comparing two text boxes dates,
so please give me code regarding mine.......
it was very help ful tome .please........
thnx.........

Take a look at the powerful 'TimeSpan' class
Here is a quick example
I have writing it from memory so
perhaps there are the mistakes in there:
        Dim date1 As Date = System.Date.Now

        Dim date2 As Date = "26/02/2010"

        'get the difference between two dates
        Dim diff As System.TimeSpan = date1 - date2
        'get the number of days (change on whatever you need - seconds, minutes etc)
        Dim days As Integer = diff.TotalDays
        'compare dates
        If (days < 0) Then
            MsgBox("The entered date should not be earlier than Arrival date!")
        End If



~'J'~



hi thanx a lot.......
ya it was working.......
thnx...........
Was This Post Helpful? 0
  • +
  • -

#8 fixo  Icon User is offline

  • D.I.C Regular

Reputation: 85
  • View blog
  • Posts: 335
  • Joined: 10-May 09

Re: dll file for comparing two text box dates

Posted 25 February 2010 - 03:10 AM

View Postkanuri1, on 25 February 2010 - 01:55 AM, said:

View Postfixo, on 25 February 2010 - 12:52 AM, said:

View Postkanuri1, on 25 February 2010 - 12:01 AM, said:

View PostAdamSpeight2008, on 24 February 2010 - 11:31 PM, said:

First you do know that DLLs aren't magic ibjects that which automagically do things.
All they are Classes which contain you a invoke via an instance of that class.
Use them to create a library of methods you commonly use, to save you rewriting them each time.
Or to expend the capabilities of the language.

Secondly, start to step away from the vb6 libraries(Imports Microsoft.VisualBasic) and start to use the .net versions.

So if you are comparing date, then you need a date object.

Thirdly, Never Ever trust the user to enter the correct information.
Validate all user entries.

Eg. If expect the user to enter date, then check by trying to see if the string can be parsed as a date.
Convert the string to a date, doesn't check if the string is a date.


hi i understand what you say ,,,,i know dll file,,,,iam tried very much for comparing two text boxes dates,
so please give me code regarding mine.......
it was very help ful tome .please........
thnx.........

Take a look at the powerful 'TimeSpan' class
Here is a quick example
I have writing it from memory so
perhaps there are the mistakes in there:
        Dim date1 As Date = System.Date.Now

        Dim date2 As Date = "26/02/2010"

        'get the difference between two dates
        Dim diff As System.TimeSpan = date1 - date2
        'get the number of days (change on whatever you need - seconds, minutes etc)
        Dim days As Integer = diff.TotalDays
        'compare dates
        If (days < 0) Then
            MsgBox("The entered date should not be earlier than Arrival date!")
        End If



~'J'~



hi thanx a lot.......
ya it was working.......
thnx...........


Glad if that helps
Cheers :)

~'J'~
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1