7,763
社区成员
发帖
与我相关
我的任务
分享
123=01
23456=12
123=01
23456=12
234=0
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = 8 Or KeyAscii = 13 Or KeyAscii = 61 Then Exit Sub '删除键、回车键例外
If KeyAscii < 48 Or KeyAscii > 57 Then KeyAscii = 0
End Sub
Option Explicit
Dim blnLastEqual As Boolean
Private Sub Text1_Change()
Dim myStart As Long
myStart = Text1.SelStart
Text1.Text = Replace(Text1.Text, vbCrLf & vbCrLf, vbCrLf)
If myStart > Len(Text1.Text) Then
Text1.SelStart = Len(Text1.Text)
Else
Text1.SelStart = myStart
End If
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
Select Case KeyAscii
Case 8, Asc("0") To Asc("9")
blnLastEqual = False
Case Asc("=")
If Mid(Text1.Text, Text1.SelStart, 1) = "=" Then
KeyAscii = 0
Else
blnLastEqual = False
End If
Case 13
If blnLastEqual Then
KeyAscii = 0
Else
blnLastEqual = True
End If
Case Else
KeyAscii = 0
End Select
End Sub