到目前为止,这是我的代码,我有一个列表框,显示从文本文件中读取的名称。然后我有两个文本框:txtName 和 txtPhone。当名称在列表框中突出显示时,它应该在 txtName 中显示名称,在 txtPhone 中显示电话号码,但它不能正常工作。任何帮助表示赞赏。
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim memberphones() As String = IO.File.ReadAllLines("memberphones.csv")
Dim query = From line In memberphones
Let data = line.Split(","c)
Let name = data(0)
Let phone = data(1)
Select name
lstOutput.DataSource = query.ToList
txtName.Text = Name
txtPhone.Text = phone
End Sub
End Class
这是我的文本文件的内容:Carol Preiss,587-2333 Alice Rees,860-9744 Carlos Sanchez,209-4587 John Smith,576-2988