请问如何做到限制textbox中数字的小数位数,比如输入3位小数后,就不能输入小数了?谢谢
解决方案 »
- 高手求教,如下问题如何分解好.
- 求助 vb filter 问题
- 关于 利用Adobe Illustrator 把.AI文件 轉成 .pdf(200分)creazyfish(梳分头的鱼) 还有100接分
- vb6.0 在原来的窗口中打开新的弹出窗口
- 4个小问题,36分。谁能帮帮我···
- 关于SSTAB控件的问题?
- 希望高手能来帮忙解决这个问题,难度比较大,http://www.csdn.net/expert/Topic/281/281297.shtm
- 数据库区分大小写
- vb中的MshFlexgrid的一些问题????~
- 怎样通过修改注册表把把我的程序加到IE的工具拦中去?(象金山词霸)
- 如何获取指定的打印机的句柄
- 为什么我把toolbar放在coolbar上当我运行时我拉动coolbar来缩小toolbar,toolbar的按纽不能跟着缩进去?
Dim str_prvStr As String
Private Sub Form_Load()
Text1.Text = ""
End SubPrivate Sub Text1_Change()
Dim x() As String
If (IsNumeric(Text1.Text)) Then
x = Split(Text1.Text, ".")
If (UBound(x) >= 1) Then
If (Len(x(UBound(x))) > 3) Then
Text1.Text = str_prvStr
Text1.SelStart = Len(Text1.Text)
End If
End If
End If
str_prvStr = Text1.Text
End Sub
If KeyAscii = 45 And Len(Text1.Text) = 0 Then Exit Sub
If KeyAscii = 8 Then Exit Sub
If KeyAscii = 46 And Len(Text1.Text) >= 3 Then KeyAscii = 0
If KeyAscii = 46 And InStr(1, Text1.Text, ".") = 0 Then Exit Sub
If IsNumeric(Chr(KeyAscii)) Then Exit Sub
KeyAscii = 0
End Sub
s = InStr(Text1, ".")
If s And Len(Mid(Text1, s + 1)) > 2 Then KeyAscii = 0
End Sub
Dim n As Integer, s As Integer
n = InStr(Text1, ".")
s = Text1.SelStart
If n >= 1 Then
Text1 = Left(Text1, n + 3)
If s > Len(Text1) Then
Text1.SelStart = Len(Text1)
Else
Text1.SelStart = s
End If
End If
End Sub