0
我試圖從文本文件中讀取客戶信息。但我似乎只能得到第一個記錄。我假設我的問題來自每次我點擊從文件開始讀取的按鈕。有沒有辦法像做一樣做,並閱讀點擊按鈕上的下一組客戶信息?雖然循環在流讀取器?
Private Sub btnNext_Click(sender As Object, e As EventArgs) Handles btnNext.Click
searchFile = File.OpenText("Records.txt")
Dim CustomerSearch As CustomerAccounts
Using sr As StreamReader = searchFile
CustomerSearch.LastName = searchFile.ReadLine()
CustomerSearch.FirstName = searchFile.ReadLine()
CustomerSearch.CustomerNumber = searchFile.ReadLine()
CustomerSearch.Address = searchFile.ReadLine()
CustomerSearch.City = searchFile.ReadLine()
CustomerSearch.State = searchFile.ReadLine()
CustomerSearch.ZIPCode = searchFile.ReadLine()
CustomerSearch.TelephoneNumber = searchFile.ReadLine()
CustomerSearch.AccountBalance = searchFile.ReadLine()
CustomerSearch.DateOfLastPayment = searchFile.ReadLine()
txtLast.Text = CustomerSearch.LastName.ToString()
txtFirst.Text = CustomerSearch.FirstName.ToString()
txtNumber.Text = CustomerSearch.CustomerNumber.ToString()
txtAddress.Text = CustomerSearch.Address.ToString()
txtCity.Text = CustomerSearch.City.ToString()
txtState.Text = CustomerSearch.State.ToString()
txtZip.Text = CustomerSearch.ZIPCode.ToString()
txtTelephone.Text = CustomerSearch.TelephoneNumber.ToString()
txtBalance.Text = CustomerSearch.AccountBalance.ToString()
txtPayment.Text = CustomerSearch.DateOfLastPayment.ToString()
End Using
End Sub
這是我的例子txt文件:
Stockes
Colton
855
134 Street
Scottsdale
az
85260
9283806778
200
11/2/2017
Brianne
Riggle
1234
16553
Scottsdale
az
8560
555555
110
11/9/2017
Gillespie
Delinda
7268 Goonight ln
Prescott
Az
86314
6026848036
10
11/20/2017
真棒謝謝SO 3 M UCH。我正在做類似的事情,並被卡住了。這是一個任務,因爲這正是我正在尋找的! –
@BrianneRiggle請注意我做了一些編輯。 – MrGadget