vb ListBox 控件如何对文本操作
- 提问者网友:记得曾经
- 2021-07-29 19:18
- 五星知识达人网友:一把行者刀
- 2021-07-29 20:31
Private Sub AddColor_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AddColor.Click
Using sw As StreamWriter = New StreamWriter("color.txt")
ListBox1.Items.Add(TextBox2.Text)
For i = 0 To ListBox1.Items.Count - 1
sw.WriteLine(ListBox1.Items.Item(i))
Next
sw.Close()
End Using
End Sub
Private Sub ReadColor_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ReadColor.Click
Using sr As StreamReader = New StreamReader("color.txt")
Dim line As String
While Not sr.EndOfStream
line = sr.ReadLine()
ListBox1.Items.Add(line)
End While
sr.Close()
End Using
End Sub
- 1楼网友:舊物识亽
- 2021-07-29 20:51