Okay, I have a program that runs through textfiles or csv to find the date and output weither the date is found or not. It uses the VB6 DatePicker control, which is located at the MS common controls 6.0-2.
Right now I have it so that it finds 'specific text' an textfile, and only gives THOSE lines with the text in them. However, there is also a date range I am now adding, which will find only specific dates too.
Using the code below works find to get the date from the line -- 'str1' does well...
Basicly it grabs the line, checks for valid dates, bookmarks the number it if it finds it in a specific place in the array so it can be processed faster 'next line' until the end of the file, and then makes checks to see if the date in the file is = to the date range I have specified.
However, the program goes from about 6 seconds without the date range filter to almost 30+ with a 300k lined file. Thus I do not think my coding is quite optimized.
Is there a better solution for this? I use CDate because the date that comes in can be 11/12/09, 11 12 09, Dec 11 09, etc.. Cdate basicly solves all this for me in a nice package.. Unless there is something 'better' then cdate, or a function 'made' manually..
Basicly I am wondering how to improve performance. I do know it will not be the 'same' speed without the date range filter, but I am wondering if I can use something other then arrays, or cdate/isdate.. Or by looking at the coding below, a way to increase performance minor/major.
Line Input #intFileHandle2, str1
validline = 0
If Check1.Value = 1 Then
validon = Replace(str1, Chr(34), "")
validon = Replace(validon, "'", "")
marray = Split(str1, ",")
If validfound = -1 Then
For i = 0 To UBound(marray)
If IsDate(marray(i)) Then
validfound = i
If validfound <> -1 Then
If IsDate(marray(validfound)) Then
currentdate = DTPicker1.Value
finddate = Format(CDate(marray(validfound)), "short date")
Do While currentdate <= DTPicker2.Value
If finddate = currentdate Then
validline = 1
currentdate = currentdate + 1
'Do rest of stuff here with validline being equal to 1...