仅使用部分文字搜索标题?

时间:2016-03-07 23:32:54

标签: vb.net

标题说明了一切,我需要帮助使我的搜索输入框找到标题并在用户仅在搜索之前键入部分电影标题时显示它。这就是我现在所拥有的并且效果很好,但您必须输入完整的标题。任何帮助,将不胜感激!感谢

    Private Sub btnSearch_Click(sender As Object, e As EventArgs)Handles btnSearch.Click

    'Searches for movie in listbox
    Dim strDVDtitle As String

    strDVDtitle = InputBox("Enter Movie Title:")

    Dim X As Integer = 0

    Dim bolDVDFound As Boolean = False


    For X = 0 To count - 1
        If DVDS(X).DVDtitle = strDVDtitle Then
            txtDVDyear.Text = DVDS(X).DVDyear
            txtDVDtitle.Text = DVDS(X).DVDtitle
            txtDVDyear.Text = DVDS(X).DVDyear
            txtDVDruntime.Text = DVDS(X).DVDruntime
            txtDVDrating.Text = DVDS(X).DVDrating
            bolDVDFound = True
        End If
    Next

    If bolDVDFound = False Then
        MessageBox.Show("Movie not found")

    End If
End Sub 

1 个答案:

答案 0 :(得分:1)

您可以使用包含字符串方法,如下所示:

Dim actualTitle = "The Martian"

If actualTitle.ToLower().Contains(strDVDtitle.ToLower()) Then
  MsgBox("Match!")
End If