Listbox Tutorial - Source Code
Codes:
Public Class Form1
Private Sub cmdAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdAdd.Click
lb1.Items.Add(tb1.Text)
lb1.SelectedIndex = lb1.SelectedIndex + 1
End Sub
Private Sub cmdRem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdRem.Click
lb1.Items.Remove(lb1.SelectedItem)
End Sub
Private Sub cmdSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdSave.Click
IO.Directory.CreateDirectory("C:\Test")
Dim w As New IO.StreamWriter("C:\Test\test.txt")
Dim i As Integer
For i = 0 To lb1.Items.Count - 1
w.WriteLine(lb1.Items.Item(i))
Next
w.Close()
End Sub
Private Sub cmdLoad_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdLoad.Click
Dim r As New IO.StreamReader("C:\Test\test.txt")
While (r.Peek() > -1)
lb1.Items.Add(r.ReadLine)
End While
r.Close()
End Sub
End Class
_________________________________________________________________________
Here is the video tutorial:
Subscribe to:
Post Comments (Atom)
Blog Archive
-
▼
2010
(13)
-
▼
April
(6)
- Textbox - Select All (Ctrl+A) and Scroll Visual Ba...
- Run Program on Windows Startup Tutorial Visual Ba...
- Email Validation Entered Into Textbox Tutorial Vis...
- Visual Basic Send Email - Smtp Tutorial - {VB.net}
- How to make form move Borderless (No Title Bar) Vi...
- Listbox Tutorial - Add, Remove Item, Save, Reload ...
-
▼
April
(6)
S
ReplyDelete