16,550
社区成员
发帖
与我相关
我的任务
分享
var input = "ertyuiop120asdfas";
if(input.contains("120"))//show message to client;
Dim MstrWord As String = String.Empty
Dim MBol As Boolean = False
Dim MInt As Integer = 0 '已经匹配的字母数目
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
MstrWord = "happy" '要匹配的关键字
End Sub
Private Sub TextBox1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyDown
Dim strFword As String = String.Empty
If MBol = True Then '如果标准为true,则继续进行下面字母的匹配
strFword = MstrWord.Substring(MInt, 1).Trim
If e.KeyCode = Asc(strFword.ToUpper) Then
MBol = True
MInt = MInt + 1
If MInt = MstrWord.Trim.Length Then
MsgBox("匹配happy成功!")
MBol = False
MInt = 0
End If
Else
MBol = False
MInt = 0
End If
Else
'根据ascii码值匹配,如果关键字第一个字母匹配则把标志置为true
strFword = MstrWord.Substring(0, 1).Trim
If e.KeyCode = Asc(strFword.ToUpper) Then
MBol = True
MInt = MInt + 1
Else
MBol = False
End If
End If
End Sub