老师好 下面是文本框输入字符查询的代码,我想在输入字符后自动生成一个空格再输入来回输入6组字符6个空格,现在想请老师帮忙,谢谢。
Dim txt As String = e.Sender.Text
Dim tbl As Table = Tables("号码_Table1")
Dim aa() As String = txt.Split(" ")
Dim s As String = "1=1 "
For Each a As String In aa
s = s & " and 号码_红球 Like '%" & a & "%'"
Next
tbl.Filter = s
【
想在输入字符后自动生成一个空格】 -- 输入几个字符后添加空格?电脑怎么知道你想输入几个字符?
textchanged事件
If e.Sender.Text = "" Then
Vars("a") = 0
End If
Enter事件Vars("a") = 0
KeyPress事件
If Char.IsNumber(e.KeyChar) Then
If e.Sender.Text.Length > 1 Then
If Vars("a") = 0 Then
e.Cancel = True
e.Sender.Text = e.Sender.Text & " " & e.KeyChar
e.Sender.SelectionStart = e.Sender.Text.Length
Vars("a") = Vars("a") + 1
Else
Vars("a") = 0
End If
End If
End If
[此贴子已经被作者于2024/10/18 13:29:47编辑过]
文本框TextChanged事件
systemready = False
Dim s As String = e.sender.text.replace(" ", "")
Dim p As String = ".{2}(?!$)"
Dim rgx = New System.Text.RegularExpressions.Regex(p, System.Text.RegularExpressions.RegexOptions.IgnoreCase)
Dim idx As Integer = e.sender.SelectionStart
e.sender.Text = rgx.Replace(s, "$0 ")
e.Sender.SelectionStart = idx + s.length \ 2
systemready = True
老师,报错。
此主题相关图片如下:2024-10-18 12 33 44.png
textchanged事件
If e.Sender.Text = "" Then
Vars("a") = 0
End If
Enter事件
Vars("a") = 0
KeyPress事件
If Char.IsNumber(e.KeyChar) Then
If e.Sender.Text.Length > 1 Then
If Vars("a") = 0 Then
e.Cancel = True
e.Sender.Text = e.Sender.Text & " " & e.KeyChar
e.Sender.SelectionStart = e.Sender.Text.Length
Vars("a") = Vars("a") + 1
Else
Vars("a") = 0
End If
End If
End If