validate start date is not greater then end date

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • lillyehrhart
    New Member
    • Jun 2015
    • 48

    #1

    validate start date is not greater then end date

    I have a webpage with some textboxes and drop down lists. I have already validated to make sure that something is selected, now i want to make sure that the start date is not greater than the end date. this is the code i have for that function
    Code:
    Private Function ValidInput() As Boolean
           
            Dim arTextBoxes() As TextBox = {
                tbShipper,
                tbConsignee,
                tbEnterStrtEntDate,
                tbEnterEndShipDate,
                tbEnterStrtShipDate,
                tbEnterEndEntDate,
                tbProNumber,
                tbBillOfLadingNumber,
                tbCheckNumber,
                tbInvoiceNo
            }
    
    
            For Each tb In arTextBoxes
                tb.Text = Trim(tb.Text)
                If tb.Text.Length > 0 Then
                    Return True
                End If
            Next
    
           
    
    
            'if we made it here, then none of the tbs are filled in.
            If ddlScacs.SelectedIndex <> 0 Then
                Return True
            End If
            If ddlLocation.SelectedIndex <> 0 Then
                Return True
            End If
    
            If (tbEnterStrtShipDate.Text > tbEnterEndShipDate.Text) Then
               FBErrMess.Visible = True
                FBErrMess.Text = "Start date cannot come after end date."
            End If
    
    
            'so at this point, no tbs, no ddls used, yell at them.
    
            _dbmanager.ClearData()
            RefreshPagers()
            FBErrMess.Text = "Please enter search criteria before searching."
            FBErrMess.Visible = True
            Return False
    
        End Function
    in that function, the start date and end date validation is not working at all. how do i make this work?
  • Luk3r
    Contributor
    • Jan 2014
    • 300

    #2
    You should convert your date strings into dates using CDate. Something like this should help.

    Comment

    Working...