I am making a password manager for myself and am storing all of the data locally within a text file. I am not worried about security at the moment, simply trying to get it to work.
I can read from the text file fine and have each of my entries split with commas, but I can't figure out how to properly format my for loop
to get them in the correct order
Here is how the data looks within pass.txt
Gmail,07/31/2020,password,
Facebook,07/31/2020,password,
I have 3 columns, Service
,Last Changed
, and Password
. Currently, my data fills the first column from the top down until the end of my array splitData
and then does the same for the remaining 2 columns
My thought is that I need a nested for loop
within my existing one, but am stuck on the logic
Public Class Form2
Private thedatatable As New DataTable
Private workDirectory = My.Computer.FileSystem.CurrentDirectory
Private rw As System.IO.StreamReader
Private fileContents As String
Private splitData As String()
Private Sub Form2_Load(sender As Object, e As EventArgs) Handles MyBase.Load
With thedatatable
.Columns.Add("Service", System.Type.GetType("System.String"))
.Columns.Add("Last Changed", System.Type.GetType("System.String"))
.Columns.Add("Password", System.Type.GetType("System.String"))
End With
workDirectory += "\pass.txt"
rw = My.Computer.FileSystem.OpenTextFileReader(workDirectory)
fileContents = rw.ReadToEnd()
'reads pass.txt to string array while splitting at commas
splitData = fileContents.Split(New Char() {","c})
Dim word As String
For Each word In splitData REM iterates for each split word
Dim newrow As DataRow = thedatatable.NewRow
newrow("Service") = word
newrow("Last Changed") = word
newrow("Password") = word
thedatatable.Rows.Add(newrow)
Next
DataGridView1.DataSource = thedatatable
End Sub
End Class