Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Imports System.IO
- Public Class Form1
- Dim a As StreamReader
- Dim b As String
- Dim c As String = "C:\Program Files (x86)\temp\hungvb.txt"
- Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
- If Not File.Exists(c) Then
- Dim d As FileStream
- d = File.Create(c)
- d.Close()
- End If
- 'read file
- Try
- ComboBox1.Items.Clear()
- a = File.OpenText(c)
- While a.Peek <> -1
- b = a.ReadLine()
- ComboBox1.Items.Add(b)
- End While
- a.Close()
- Catch ex As Exception
- MsgBox(ex.Message)
- End Try
- End Sub
- Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
- If TextBox1.Text = Nothing Then
- ' Me.Text = "Enter A Password To Be Saved"
- Else
- File.AppendAllText(c, TextBox1.Text & vbCrLf)
- TextBox1.Text = ""
- ' MsgBox("Saved Pass")
- ReadFile()
- End If
- End Sub
- Private Sub ReadFile()
- Try
- ComboBox1.Items.Clear()
- a = File.OpenText(c)
- While a.Peek <> -1
- b = a.ReadLine()
- ComboBox1.Items.Add(b)
- End While
- a.Close()
- Catch ex As Exception
- MsgBox(ex.Message)
- End Try
- End Sub
- End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement