[Save , Load , Search , Clear]
Public Class Form1
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
ListBox1.Items.Add(TextBox1.Text)
End Sub 'Add
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Dim ofd As New SaveFileDialog
With ofd
.FileName = "*.txt"
.Title = "Choose a dir..."
.Filter = "TxtFile(*.txt)|*.txt"
.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop)
If .ShowDialog = Windows.Forms.DialogResult.OK Then
Try
Dim w As New IO.StreamWriter(.FileName)
For i = 0 To ListBox1.Items.Count - 1
w.WriteLine(ListBox1.Items.Item(i))
Next
w.Close()
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End If
End With
End Sub 'Save
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
ListBox1.Items.Clear()
End Sub 'Clear
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
For i As Integer = 0 To ListBox1.Items.Count - 1
If ListBox1.Items(i).ToString().Contains(TextBox1.Text) Then
ListBox1.SetSelected(i, True)
Else
ListBox1.SelectedItems.Clear()
End If
Next
End Sub 'Search
End Class
Комментариев нет:
Отправить комментарий