星空网 > 软件开发 > ASP.net

vb.net实现textbox控件输入指定位数小数方法实现。

Private Sub textbox1_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles textbox1.KeyPress
If e.KeyChar = Chr(8) Then Exit Sub

If InStr(textbox1.Text, ".") = 0 Then textbox1.MaxLength = 12 Else textbox1.MaxLength = 13
If Len(textbox1.Text) - InStr(textbox1.Text, ".") = 5 And Len(textbox1.Text) <> 5 Then e.KeyChar = Chr(0)
If Len(textbox1.Text) = 7 And InStr(textbox1.Text, ".") = 0 Then
e.KeyChar = "."
Else
e.Handled = False
End If
If e.KeyChar = Chr(46) And InStr(textbox1.Text, ".") = 0 Then Exit Sub
If e.KeyChar < Chr(48) Or e.KeyChar > Chr(57) Then e.KeyChar = Chr(0)
End Sub

实现textbox只能输入X.Y的小数,最大7位,Y最大5位。




原标题:vb.net实现textbox控件输入指定位数小数方法实现。

关键词:.NET

*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。

重大影响!舱位将紧张!海运费或涨20%!:https://www.ikjzd.com/articles/108508
国际小包将暴涨164%,只求美国“不退群”!:https://www.ikjzd.com/articles/108509
德国电子家电品类市场这么大规模,你还不心动?:https://www.ikjzd.com/articles/108510
出口印度注意!印度海关舱单新规更新,11月1日起实施!:https://www.ikjzd.com/articles/108512
跨境支付公司PingPong或将收购支付牌照!:https://www.ikjzd.com/articles/108513
盘点:61家年入上亿的跨境电商独立站大卖家!:https://www.ikjzd.com/articles/108514
TikTok Shop加码直播购物,与直播平台开启合作:https://www.kjdsnews.com/a/1836348.html
TikTok Shop加码直播购物,与直播平台开启合作:https://www.goluckyvip.com/news/186218.html
相关文章
我的浏览记录
最新相关资讯
海外公司注册 | 跨境电商服务平台 | 深圳旅行社 | 东南亚物流