以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  [求助] 全角转半角的顺序问题  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=75011)

--  作者:15986720145
--  发布时间:2015/9/24 15:14:00
--  [求助] 全角转半角的顺序问题
在窗口中的 TextBox1的TextChanged事件代码如下:

e.Form.Controls("TextBox1").Text = StrToNarrow(e.Form.Controls("TextBox1").Text)

当我输入192.168.1.123 时,TextBox1的内容变成了 32.1.186.1291 了.

请问 怎么才能把那个顺序正确要适时显示到TextBox1中。 谢谢!!!
[此贴子已经被作者于2015/9/24 15:23:47编辑过]

--  作者:czy
--  发布时间:2015/9/24 15:26:00
--  

何不放到ValueChanged事件中


--  作者:大红袍
--  发布时间:2015/9/24 15:37:00
--  

代码

 

e.sender.Text = StrToNarrow(e.sender.Text)
e.sender.SelectionStart =e.sender.text.length


--  作者:15986720145
--  发布时间:2015/9/24 17:34:00
--  
ValueChanged 事件,必须要等离开TextBox控件才触发的。
必须放在TextChanged事件,才能实时……

--  作者:大红袍
--  发布时间:2015/9/24 17:38:00
--  
Dim idx As Integer = e.Sender.SelectionStart
e.sender.Text = StrToNarrow(e.sender.Text)
e.sender.SelectionStart = idx