Resolvido pelo Basole. Vide Eventos KeyPress e Change:
Private Sub TxtValor_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
Select Case KeyAscii
Case 44, 8, 48 To 57
If KeyAscii = 44 Then If InStr(1, TxtValor, ",", vbTextCompare) > 0 Then KeyAscii = 0
Case Else
KeyAscii = 0
End Select
End Sub
Private Sub TxtValor_Change()
Dim bMax As Byte
bMax = VBA.Len(TxtValor.Value)
If VBA.InStr(1, TxtValor.Value, ".", vbTextCompare) > 0 Or _
VBA.InStr(1, TxtValor.Value, ",", vbTextCompare) > 0 Then
If TxtValor.MaxLength = bMax + 1 Or TxtValor.MaxLength = bMax Then
Else
TxtValor.MaxLength = bMax + 2
End If
Else
TxtValor.MaxLength = 0
End If
End Sub
Postado : 11/12/2019 6:57 pm