|
nmcfbgttyl 发表于 2013-1-8 19:35
谢谢赵老师,回复晚了,请谅解,因为今天有事,一天没开电脑。
VBA的代码正是我要实现的效果,可是我想在V ...
你把哑巴逼得说了话,如果合乎要求,要多多加鲜花啊!
类模块clsTxt:- Public WithEvents Txtbox As TextBox
- Private Sub Txtbox_Change()
- Dim s As String, t As String, a, i As Integer
- s = Txtbox.Text
- If InStr(s, ".") Then
- If Left(s, 1) = "." Then
- Txtbox.Text = Mid(s, 2)
- Else
- a = Split(s, ".")
- If UBound(a) > 1 Then
- t = a(0) & "."
- For i = 1 To UBound(a)
- t = t & a(i)
- Next
- Txtbox.Text = t
- End If
- End If
- End If
- With CreateObject("vbscript.regexp")
- .Global = True
- .Pattern = "[^0-9.]+"
- If .test(s) Then
- Txtbox.Text = .Replace(s, "")
- End If
- End With
- Txtbox.SelStart = Len(s)
- End Sub
复制代码 |
|