Dear Sir,
I'm Trying to Import dat files to list via dapper and bind DataGridView with custom start and end date in VB.Net
Please Guide Me
Thanks
Please Guide Me
Desired Result
so I want to start from the date 17-03-2024 up to 25-03-2024 even in the dat file only record rom the date 18-03-2024 up to 19-03-2024
for columns IN/OUT if the value is 0 then it means IN and if the value is 1 it means OUT
ID |
DATE |
TIME |
FP |
IN/OUT |
OTHERS1 |
OTHERS2 |
5010 |
17-03-24 |
|
|
IN |
|
|
5010 |
17-03-24 |
|
|
OUT |
|
|
5014 |
17-03-24 |
|
|
IN |
|
|
5014 |
17-03-24 |
|
|
OUT |
|
|
5010 |
18-03-24 |
06:59:10 |
1 |
IN |
0 |
0 |
5014 |
18-03-24 |
07:11:00 |
1 |
IN |
0 |
0 |
5014 |
18-03-24 |
16:32:09 |
1 |
OUT |
0 |
0 |
5010 |
18-03-24 |
16:33:19 |
1 |
OUT |
0 |
0 |
5010 |
19-03-24 |
07:05:15 |
1 |
IN |
0 |
0 |
5014 |
19-03-24 |
07:31:19 |
1 |
IN |
0 |
0 |
5014 |
19-03-24 |
16:30:50 |
1 |
OUT |
0 |
0 |
5010 |
19-03-24 |
16:31:12 |
1 |
OUT |
0 |
0 |
5010 |
20-03-24 |
|
|
IN |
|
|
5010 |
20-03-24 |
|
|
OUT |
|
|
5014 |
20-03-24 |
|
|
IN |
|
|
5014 |
20-03-24 |
|
|
OUT |
|
|
5010 |
21-03-24 |
|
|
IN |
|
|
5010 |
21-03-24 |
|
|
OUT |
|
|
5014 |
21-03-24 |
|
|
IN |
|
|
5014 |
21-03-24 |
|
|
OUT |
|
|
5010 |
22-03-24 |
|
|
IN |
|
|
5010 |
22-03-24 |
|
|
OUT |
|
|
5014 |
22-03-24 |
|
|
IN |
|
|
5014 |
22-03-24 |
|
|
OUT |
|
|
5010 |
23-03-24 |
|
|
IN |
|
|
5010 |
23-03-24 |
|
|
OUT |
|
|
5014 |
23-03-24 |
|
|
IN |
|
|
5014 |
23-03-24 |
|
|
OUT |
|
|
5010 |
24-03-24 |
|
|
IN |
|
|
5010 |
24-03-24 |
|
|
OUT |
|
|
5014 |
24-03-24 |
|
|
IN |
|
|
5014 |
24-03-24 |
|
|
OUT |
|
|
5010 |
25-03-24 |
|
|
IN |
|
|
5010 |
25-03-24 |
|
|
OUT |
|
|
5014 |
25-03-24 |
|
|
IN |
|
|
5014 |
25-03-24 |
|
|
OUT |
|
|
Below Mycode :
Protected Sub ReadDat()
Dim fName As String = ""
OpenFileDialog1.InitialDirectory = "D:\TestFile"
OpenFileDialog1.Filter = "Dat files(*.Dat)|*.Dat"
OpenFileDialog1.RestoreDirectory = True
If (OpenFileDialog1.ShowDialog() = DialogResult.OK) Then
fName = OpenFileDialog1.FileName
End If
If System.IO.File.Exists(fName) = True Then
Dim lines As String() = File.ReadAllLines(fName)
Dim datfiles As List(Of datfiles) = New List(Of datfiles)()
For i As Integer = 0 To lines.Length - 1
If Not String.IsNullOrEmpty(lines(i).Trim()) Then
Dim data As String() = lines(i).Trim().Split(CType(vbTab, Char()))
datfiles.Add(data(0),
data(1).ToString().Split(" "c)(0),
data(1).ToString().Split(" "c)(1),
data(2),
If(data(3).ToString() = "0", "IN", "OUT"),
data(4),
data(5))
End If
Next
' Use the DataTable to populate the DataGridView.
DataGridView1.Visible = True
DataGridView1.DataSource = dt
DataGridView1.ReadOnly = True
Else
MsgBox("File Does Not Exist")
End If
End Sub
link sample file dat