我需要创建一个程序,可以搜索用户想要搜索的字母。用户将在TextBox中写下一些东西,当他/她按下搜索时,会出现一个InputBox,要求他在InputBox上写一个字母。然后程序会告诉你有很多时间字母出现在TextBox中。这就是我到目前为止所做的:
Public Class Form1
Private Sub BtnClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnClear.Click
TxtboxInput.Clear()
End Sub
Private Sub BtnQuit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnQuit.Click
Me.Close()
End Sub
Private Sub BtnSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnSearch.Click
Dim intStartIndex As Integer
Dim intFoundIndex As Integer
Dim counter = 0
Dim hitcounter = 0
Dim blnFlag = True
Try
InputBox(" Enter Letters", "Input Needed")
Catch
End Try
End Sub
End Class
答案 0 :(得分:0)
我不确定你到底想要做什么,但如果你把它限制在一个角色,那么这样的事情应该有效。
Private Sub BtnSearch_Click(sender As System.Object, e As System.EventArgs) Handles BtnSearch.Click
Dim counter = 0
Try
Dim search As String = InputBox(" Enter Letters", "Input Needed")
For Each c As Char In TxtboxInput.Text
If c.ToString = search Then
counter += 1
End If
Next
Catch
End Try
End Sub