你自己做下防错处理吧Private Sub Text1_KeyUp(KeyCode As Integer, Shift As Integer) If KeyCode >= 96 And KeyCode <= 105 Then'当输入的是数字时判断 If Len(Text1.Text) = 2 Then Text1.Text = Text1.Text & "°" ElseIf Len(Text1.Text) = 5 Then Text1.Text = Text1.Text & "'" ElseIf Len(Text1.Text) = 8 Then Text1.Text = Text1.Text & """" End If Text1.SelStart = Len(Text1.Text)‘确定光标位置 Text1.SelLength = Len(Text1.Text) End If End Sub
If KeyCode >= 96 And KeyCode <= 105 Then'当输入的是数字时判断
If Len(Text1.Text) = 2 Then
Text1.Text = Text1.Text & "°"
ElseIf Len(Text1.Text) = 5 Then
Text1.Text = Text1.Text & "'"
ElseIf Len(Text1.Text) = 8 Then
Text1.Text = Text1.Text & """"
End If
Text1.SelStart = Len(Text1.Text)‘确定光标位置
Text1.SelLength = Len(Text1.Text)
End If
End Sub