Listview:displaying froma text file

Johnson

Well-known member
Joined
Mar 6, 2009
Messages
158
Programming Experience
Beginner
Hello, on my application i have a username and password form that saves the username & password

It's not meant to be secure, and it writes to a text file displaying as so

VB.NET:
Johnson:password1
Newname:password2
Newname2:password3

here is the code

VB.NET:
    Private Sub cmdPostAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdPostAdd.Click
        'Add new username and password

        If txtPostName.Text <> "" And txtPostValue.Text <> "" Then
            Dim liNew As ListViewItem = lvPost.Items.Add(txtPostName.Text)
            liNew.SubItems.Add(txtPostValue.Text)
            txtPostName.Text = ""
            txtPostValue.Text = ""
            Dim i As Integer = 0
            Dim sTemp As String = ""

            ' Write All Items and subitems to a file
            With lvPost
                .View = View.Details
                For i = 0 To .Items.Count - 1
                    ' Collect Item and subitems as comma separated elements 
                    ' sTemp += .Items(i).Text & ","
                    sTemp += .Items(i).SubItems(0).Text & ":"
                    sTemp += .Items(i).SubItems(1).Text & vbNewLine
                Next
            End With
            My.Computer.FileSystem.WriteAllText("C:\UIS.txt", sTemp, False)

        End If
    End Sub

This all works fine, but i have no idea how to reload this information when the form loads.

Obviously it needs to read the string, the seperate the username and password.

i have been trying for hours

also is it possible to password char the password section in the listview? at the moment it can be read.

thanks
 
I don't mean to sound too critical because that's pretty much how everyone starts out. The sooner a new developer can learn to divide and conquer though, the better for them because solving multiple small problems is always easier than solving one big problem. The further you go the better you get at identifying the smaller problems but the first step is always to look at what your app should do from the user's perspective. That will usually provide you with your first set of subproblems, which you would then break down further if possible.
 
Back
Top