Advertisement
Guest User

Untitled

a guest
Jun 27th, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. Dim dt As New DataTable
  2. dt.Columns.Add("Date")
  3. dt.Columns.Add("Gross Sales")
  4.  
  5. Dim Folder As New IO.DirectoryInfo("c:test")
  6. Dim lstLines As New List(Of String)
  7.  
  8.  
  9. For Each fileentries As String In Folder.GetFiles("s*", IO.SearchOption.AllDirectories).OrderByDescending(Function(x) x.Name).Select(Function(x) x.FullName)
  10. lstLines.AddRange(File.ReadAllLines(fileentries))
  11. Next
  12.  
  13.  
  14. Dim i As Integer
  15. Dim OuterLoopIterations As Integer = CInt(lstLines.Count / 22)
  16. For iterations = 0 To OuterLoopIterations - 1
  17. Dim row = dt.NewRow
  18. For col = 0 To 21
  19. row(col) = lstLines(i).Remove(0, 2) 'i have removed the first 2 characters of each string
  20.  
  21. i += 1
  22. Next
  23. dt.Rows.Add(row(2), row(5), row(12), row(13), row(14), row(15), row(7), row(8), row(11))
  24.  
  25. Next
  26.  
  27. DataGridView1.DataSource = dt
  28. 'the code i tried applying
  29. DataGridView1.Columns("Gross Sales").DefaultCellStyle.Format = "##,0"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement