标题说明了这一切,我需要帮助使我的搜索输入框找到标题并在用户在搜索前仅键入部分电影标题时显示它。这就是我现在拥有的,并且效果很好,但是你必须输入完整的标题。任何帮助,将不胜感激!由于通过仅搜索文本的一部分来查找标题?
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
[vb.net?:查找字符串中的字符串的位置]的可能的复制(HTTP://计算器.com/questions/1639381/vb-net-finding-a-position-of-a-string-within-a-string) – wimh
我试过indexof ...没有工作。我只需要将输入框的输入文本与我的Structure中的DVDtitles进行比较以找到标题。 – ZweiiHander
你尝试了什么?例如:'如果DVDS(X).DVDtitle.IndexOf(strDVDtitle)> -1然后'? – wimh