Sub Globals
'Declare the global variables here.
Dim keys(0)
Dim pattern
End Sub
Sub App_Start
keys() = Array("[0]","[1]","[2ABCabc]","[3DEFdef]","[4GHIghi]" _
,"[5JKLjkl]","[6MNOmno]","[7PQRSpqrs]","[8TUVtuv]","[9WXYZwxyz]")
Form1.Show
FillWithRandomData
Form1.Show
ofrm.New1(false)
ofrm.FromControl("Form1")
ofrm.SetProperty("KeyPreview",true)
pattern = "^.*"
match.New1
End Sub
Sub Form1_KeyPress (specialKey)
If IsNumber(Chr(specialKey)) OR specialKey = 8 Then
If IsNumber(Chr(specialKey)) Then
alStack.Add(StrLength(pattern))
pattern = pattern & keys(Chr(specialKey)) & ".*"
Else If specialKey = 8 Then
If alStack.Count > 0 Then
pattern = SubString(pattern,0,alStack.Item(alStack.Count-1))
alStack.RemoveAt(alStack.Count-1)
Else
Return
End If
End If
txtFilter.Text = ""
regex.New2(pattern & "$",false,true)
Match.Value = Regex.Match(txtFull.Text)
Do While Match.Success
txtFilter.Text = txtFilter.Text & match.String & crlf
match.Value = Match.NextMatch
Loop
End If
End Sub
Sub FillWithRandomData
For i = 1 To 100
name = ""
For i2 = 1 To 5
name = name & Chr(Rnd(Asc("a"),Asc("z")+1))
Next
txtFull.Text = txtFull.Text & name & crlf
Next
End Sub
Sub txtFull_KeyPress (key)
txtFull.IgnoreKey
End Sub
Sub txtFilter_KeyPress (key)
txtFilter.IgnoreKey
End Sub