Salve a tutti,
ho il segunte codice:
Volevo sapere:codice:Private Sub TextBox1_KeyPress(ByVal KeyAscii As MsForms.ReturnInteger) Select Case KeyAscii Case 0 To 31, 44, 48 To 57 Exit Sub Case Else KeyAscii = 0 End Select End Sub
1 - Dovrei applicare tale codice a ben 20 TextBox. E' possibile evitare di ripeterlo? Cioè evitare questi due modi:
Metodo A:
Metodo B: Creo sub Esterna e poi la richiamo nelle text_Keypresscodice:Private Sub TextBox1_KeyPress(ByVal KeyAscii As MsForms.ReturnInteger) Select Case KeyAscii Case 0 To 31, 44, 48 To 57 Exit Sub Case Else KeyAscii = 0 End Select End Sub Private Sub TextBox2_KeyPress(ByVal KeyAscii As MsForms.ReturnInteger) Select Case KeyAscii Case 0 To 31, 44, 48 To 57 Exit Sub Case Else KeyAscii = 0 End Select End Sub
2- Dovrei inserire dopo aver digitato i primi due numeri la virgola. Ora se l'utente non la digita dovrei far comparire un msgbox o dovrei fare in modo che la inserisca direttamente il programma. Mi sapreste dire come?codice:Sub Validatxt () Select Case KeyAscii Case 0 To 31, 44, 48 To 57 Exit Sub Case Else KeyAscii = 0 End Select End Sub Private Sub TextBox1_KeyPress(ByVal KeyAscii As MsForms.ReturnInteger) Call Validatxt End Sub
Grazie a tutti,![]()
![]()
![]()

Salve a tutti,
Rispondi quotando