以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  [求助]文本框第一个字符不能为“0”  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=162773)

--  作者:2425004926
--  发布时间:2021/4/15 11:18:00
--  [求助]文本框第一个字符不能为“0”
文本框输入的是数字,且第一个字符串不能为"0",红色的代码总是出错
KeyPress事件
If Char.IsDigit(e.keychar) = False Then
    e.Cancel = True
End If
If e.sender.text.Chars(0) = "0" Then
    e.sender.text = ""
End If



--  作者:有点蓝
--  发布时间:2021/4/15 11:43:00
--  
KeyPress事件
If Char.IsDigit(e.keychar) = False Then
    e.Cancel = True
End If

textchanged事件
If e.sender.text(0) = "0" Then
    systemready = False
    e.sender.text = ""
    systemready = True
End If

--  作者:2425004926
--  发布时间:2021/4/15 11:58:00
--  
这种表示
If e.sender.text(0) = "0" Then     是控件文本第一个字符是“0”
If e.sender.text(1) = "0" Then     是控件文本第二个字符是“0”
是这样吗?

--  作者:有点蓝
--  发布时间:2021/4/15 12:04:00
--  
是的
--  作者:2425004926
--  发布时间:2021/4/15 12:10:00
--  
 好的,谢谢