Ciao Artemio,
posto due esempi che consentono solo l'inserimento di numeri nelle Txt1 e txt2:
codice:
Private Sub Txt1_Change()
Dim ix As String
Dim ixs As String
Dim ix2 As String
ix = Len(Txt1.Text)
If ix = 0 Then
Exit Sub
End If
ixs = (Txt1.Text)
If IsNumeric(Txt1.Text) Then
Txt1.SetFocus
Else
MsgBox "Casella di testo Txt1: INSERIRE SOLO VALORI NUMERICI!", vbCritical, "nomedeltuoprogramma"
ix2 = Mid(ixs, 1, (ix - 1))
Txt1.Text = ix2
Exit Sub
End If
End Sub
'----------------------------------------------------------------------------------
Private Sub text2_change()
Dim txtlen As Double
On Error Resume Next
If Not IsNumeric(Text2.Text) Then
txtlen = Len(Text2.Text) - 1
Text2.Text = Mid(Text2.Text, 1, txtlen)
Text2.SelStart = txtlen + 1
End If
End Sub