Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 953561
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T00:04:18+00:00 2026-05-16T00:04:18+00:00

My Application uses For…Next loops to read a spreadsheet into a DataSet and then

  • 0

My Application uses For…Next loops to read a spreadsheet into a DataSet and then display information from it based on the results of search conditions (search term and a date range).

I’m having a problem with the data where, if I run a search that should return the first 400 rows in the spreadsheet, I’m only getting around 200 results. I know the search should return the 400 rows because I checked it in the spreadsheet before running the search.

I think my problem might be caused by my date comparisons. I think the problem might be that I’m comparing String value, so if anyone can show me a more efficient way of comparing dates, then that’ll be great.

Here’s my code:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    If ListBox1.Items.Count <> 0 Then : ListBox1.Items.Clear() : End If
    Dim j As Integer = 0
    If TextBox1.Text.Length = 4 Then
        For i As Integer = 0 To CallData.Tables(0).Rows.Count - 1
            'MsgBox(CallData.Tables(0).Rows(i)(2) & " - FROM( " & DateTimePicker1.ToString & " ) TO( " & DateTimePicker2.ToString & " )")
            If CallData.Tables(0).Rows(i)(3).ToString = TextBox1.Text _
            And CallData.Tables(0).Rows(i)(2).ToString > DateTimePicker1.Value.ToString _
            And CallData.Tables(0).Rows(i)(2).ToString < DateTimePicker2.Value.ToString Then
                ListBox1.BeginUpdate()
                ListBox1.Items.Add(CallData.Tables(0).Rows(i)(2).ToString)
                ListBox1.EndUpdate()
                j = j + 1
            End If
        Next

        Label1.Text = j & " records found."
    End If
End Sub
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T00:04:19+00:00Added an answer on May 16, 2026 at 12:04 am

    When you compare strings to each other it doesn’t have anything to do with dates, it compares them alphabetically.
    You can just cast the object from the row to a date and then compare.

    Change:

    CallData.Tables(0).Rows(i)(2).ToString > DateTimePicker1.Value.ToString
    CallData.Tables(0).Rows(i)(2).ToString < DateTimePicker2.Value.ToString 
    

    to:

    CType(CallData.Tables(0).Rows(i)(2), DateTime) > DateTimePicker1.Value
    CType(CallData.Tables(0).Rows(i)(2), DateTime) < DateTimePicker2.Value
    

    Btw, I’m no vb expert but I guess this code should do the trick 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My application uses a MapView which will display multiple places. I have the latitude
My application uses a 3rd party dll. If I remove myapp.exe.local file from my
My application uses MS access database to save some sensitive information. Though that information
my application uses a webView to display flash webpage. And there is a inner
Our application uses H2Sharp to access a H2 database from C# (Framework v4). Recently
My application uses Mochiweb. As I understand, rebar fetches the latest version from Github
My application uses Google to search for information and retrieves it. After a few
My application uses quite a lot of pictures that are downloaded from the internet
My application uses an SQLite database with FTS3. The results of a query shall
My application uses the Trace object to log information. The information is captured in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.