Visualizzazione dei risultati da 1 a 6 su 6
  1. #1
    Utente di HTML.it L'avatar di x69asterix
    Registrato dal
    Jan 2005
    Messaggi
    1,303

    [vb6] disabilitare la tastiera

    ciao,
    sto provando ad interfacciare un lettore di barcode ad un mio progetto, bene, la cosa ke mi ritorna utile e quello di sapere come fare a disabilitare tutti i tasti della tastiera, ad eccezzione di enter.
    ciao

  2. #2
    Controlla i caratteri che arrivano agli eventi KeyPress, KeyDown e KeyUp. Quelli che non ti interessano li puoi annullare cancellando il carattere che ti arriva come parametro dall'evento. Ciao
    Chi non cerca trova.

  3. #3
    Utente di HTML.it L'avatar di x69asterix
    Registrato dal
    Jan 2005
    Messaggi
    1,303
    Originariamente inviato da tas
    Controlla i caratteri che arrivano agli eventi KeyPress, KeyDown e KeyUp. Quelli che non ti interessano li puoi annullare cancellando il carattere che ti arriva come parametro dall'evento. Ciao
    ciao,
    sono riuscito a trovare questo

    Private Sub Text2_KeyPress(KeyAscii As Integer)
    If KeyAscii <> 8 And (KeyAscii < 48 Or KeyAscii > 57) Then KeyAscii = 0
    End Sub

    e per i numeri come li disabilito?

  4. #4
    Potresti fare:
    If KeyAscii <> 13 Then KeyAscii = 0
    no?

  5. #5
    Beh, quell'esempio elimina tutto tranne le cifre (codice ascii da 48 a 57) e il backspace (ascii 8). Se vuoi solo l'invio...
    codice:
    Private Sub Text1_KeyPress(KeyAscii As Integer)
        If KeyAscii <> vbKeyReturn Then
            KeyAscii = 0
        Else
            MsgBox "hai premuto return!"
        End If
    End Sub
    Ciao
    Chi non cerca trova.

  6. #6
    Utente di HTML.it L'avatar di x69asterix
    Registrato dal
    Jan 2005
    Messaggi
    1,303
    Originariamente inviato da tas
    Beh, quell'esempio elimina tutto tranne le cifre (codice ascii da 48 a 57) e il backspace (ascii 8). Se vuoi solo l'invio...
    codice:
    Private Sub Text1_KeyPress(KeyAscii As Integer)
        If KeyAscii <> vbKeyReturn Then
            KeyAscii = 0
        Else
            MsgBox "hai premuto return!"
        End If
    End Sub
    Ciao
    ok in effetti questa mi sembra + corretta.
    Hai esperienza con i codici a barre?

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.