Dim sContents As String = GetFileContents("C:\note.txt")
If sContents = "" Then
Return
Else
Me.txtUserName.Text = Mid(sContents, 1, InStr(sContents, "|") - 1)
Me.txtPassword.Text = Mid(sContents, InStr(sContents, "|") + 1, 900)
End If
End Sub
Private Sub btnOk_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOk.Click
SaveTextToFile(txtUserName.Text & "|" & Me.txtPassword.Text, "C:\note.txt")
End Sub
Public Sub GetFileContents(ByVal FullPath As String) As String
Dim strContents As String = ""
Dim objReader As StreamReader
Try
objReader = New StreamReader(FullPath)
strContents = objReader.ReadToEnd()
objReader.Close()
Return strContents
Catch Ex As Exception
End Try
Return strContentsEnd Sub
Public Function SaveTextToFile(ByVal strData As String, ByVal FullPath As String) As Boolean
Dim Contents As String = ""
Dim bAns As Boolean = False
Dim objReader As StreamWriter
Try
objReader = New StreamWriter(FullPath)
objReader.Write(strData)
objReader.Close()
bAns = True
Catch Ex As Exception
End Try
Return bAns
End Function