Moderatori: Anthony47, Flash30005
Private Sub TextBox1_Change()
If Not IsNumeric(TextBox1.Text) And TextBox1.Text <> "" Then
TextBox1.SelStart = Len(TextBox1.Text) - 1
TextBox1.SelLength = 1
End If
End Sub
Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
If Not IsNumeric(TextBox1.Text) And TextBox1.Text <> "" Then
TextBox1.SelStart = 0
TextBox1.SelLength = Len(TextBox1.Text)
Cancel = True
End If
End Sub
Private Sub txtOnlyDecimal_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtOnlyDecimal.KeyPress
' Accetto solo l'immissione di numeri interi e decimali
' Recupero il codice ascii del tasto digitato
' il tasto digitato è memorizzato nella proprietà "KeyChar"
' dell'oggetto System.Windows.Forms.KeyPressEventArgs
Dim KeyAscii As Short = Asc(e.KeyChar)
' In questo caso oltre a consentire numeri, tasto Canc
' e tasto BackSpace, devo consentire anche l'immissione
' del punto e della virgola
If KeyAscii < 48 And KeyAscii <> 24 And KeyAscii <> 8 And e.KeyChar <> "." And e.KeyChar <> "," Then
KeyAscii = 0
ElseIf KeyAscii > 57 Then
KeyAscii = 0
End If
' Faccio in modo che se l'utente digita la virgola
' mi appaia il punto
If e.KeyChar = "," Then
KeyAscii = 46 ' 46 è il codice ascii del punto
End If
' Il punto è si consentito
' ma non come primo carattere
If txtOnlyDecimal.TextLength = 0 And KeyAscii = 46 Then
KeyAscii = 0
End If
' ovviamente se c'è già un punto
' non è consentito digitarne altri
If (KeyAscii = 46) And _
txtOnlyDecimal.Text.IndexOf(".") > 0 Then
KeyAscii = 0
End If
' Reimposto il keychar
e.KeyChar = Chr(KeyAscii)
End Sub
If InStr(TextBox1.Text, ".") > 0 Then
TextBox1.Text = Replace(TextBox2.Text, ".", ",")
TextBox1.Text = Replace(TextBox2.Text, ".", ",")
Torna a Applicazioni Office Windows
Inserire dati filtrati da 2 file ad un terzo file Autore: Ricky0185 |
Forum: Applicazioni Office Windows Risposte: 14 |
Inserire add.in nella barra di avvio veloce in excel 2003 Autore: Ricky0185 |
Forum: Applicazioni Office Windows Risposte: 4 |
Visitano il forum: Nessuno e 10 ospiti