使用来自不同文本文件的两个字段执行线性搜索

时间:2019-02-21 18:50:16

标签: vb.net linear-search

使用当前代码,我已经意识到,对于我的计算机科学课程,必须有单独的文本文件而不是一个文本文件。从一个文本文件中搜索和读取字段对我来说很简单,但是我正在努力搜索两个单独的文本文件并在文本框中显示它们。当我输入客户数据时,两个文件的数组的大小也会增加。文本文件有几个字段。 IF语句执行相同的操作,但是它们通过不同的搜索功能执行此操作,关于它们来自两个不同文件的搜索,我是否可以通过相同的搜索方式执行?

一些文本文件内容:

1个文本文件: 1 7 LL11 3BY C Brymbo

DwellingID-房屋编号-邮政编码-税阶-病房

另一个文本文件:

2 James King 06/06/1999 YJames07@gmail.com uOI4gSqohd

customerID-姓名-L.name-DOB-联系人信息-密码

这是针对click事件的,它与线性搜索类有关:

Private Sub btnsearch_Click(sender As Object, e As EventArgs) Handles btnsearch.Click

    If cbsearch.Text = "View customer details" Then
        customerrecord = linsearchCustomerId(customerobject, txtsearchdetails.Text)
        If customerrecord.firstname = "" Then 'Validation, if nothing has been entered a messagebox will appear notifying the user
            MsgBox("No customers found")
        Else
            lblCustID.Text = customerrecord.CustomerID 'put the field within the label or textbox designated
            txtfirstname.Text = customerrecord.firstname
            txtlastname.Text = customerrecord.lastname
            txtvote.Text = customerrecord.Eligibletovote
            txtcontactinfo.Text = customerrecord.contactinfo
            txtdob.Text = customerrecord.DOB
            lblpassword.Text = customerrecord.password
        End If
    End If
    If cbsearch.Text = "View customer details + dwelling" Then
        dwellrecord = dwellingdetailsearch(dwellingObject, txtsearchdetails.Text) 
        If dwellrecord.dwellingID = "" Then
            MsgBox("Dwelling details not found")
        Else
            lbldwellingid.Text = dwellrecord.dwellingID
            txthousenum.Text = dwellrecord.housenum
            txtaddress.Text = dwellrecord.address
            ComboBox1.Text = dwellrecord.taxband
            Cbward.Text = dwellrecord.wardname
        End If
    End If

End Sub

这是读取文本文件的代码:

Function getalllines() As String()
        Dim filedata() As String = IO.File.ReadAllLines(Dir$(_CLfilename))
        Return filedata
End Function

0 个答案:

没有答案