我正在尝试编写一个程序,在其中读取文本文件,然后为用户提供一些选项来查看文件中的不同书籍。我正在前进,但我在弄清楚如何让用户从菜单条下拉项目中选择不同的选项时遇到问题。例如,我有在我的代码中完成的退出按钮和保存按钮(顺便说一句,这不起作用,但我正在研究如何修复它),但我也将添加、删除和更新按钮作为以及用于显示文本文件中某些内容的按钮。
您可以给我帮助的任何资源都会很棒!谢谢!
Sub Main()
Dim objReader As New StreamReader("C:\Users\HPG62-220US\Documents\Visual Studio 2010\Projects\Assignement 8\Assignement 8\bin\Debug\Books.txt")
Dim sLine As String = ""
Dim arrayText As New ArrayList()
Do
sLine = objReader.ReadLine()
If Not sLine Is Nothing Then
arrayText.Add(sLine)
End If
Loop Until sLine Is Nothing
objReader.Close()
For Each sLine In arrayText
Console.WriteLine(sLine)
Next
Console.ReadLine()
End Sub
Private Sub ExitToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) Handles ExitToolStripMenuItem.Click
Me.Close()
End Sub
Private Sub SaveToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) Handles SaveToolStripMenuItem.Click
Using writer As StreamWriter = New StreamWriter("book list.txt", True)
For Each line As String In lstBooks.Items
writer.WriteLine(line)
Next
End Using
End Sub
Private Sub Delete_Click(sender As System.Object, e As System.EventArgs) Handles Delete.Click
End Sub