Visualizzazione dei risultati da 1 a 4 su 4
  1. #1

    (Delphi 7) Errore In Tedit

    codice:
    procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char);
    begin
      if not( key in['0'..'9', #8] ) then
      begin
        MessageBeep(20);
    ShowMessage('Errore')    
    key := #0;
      end;
    end;
    In questo caso dovrebbe permettermi solo l'inserimento di numeri da 0 a 9. Invece non funziona non mi da nessun errore. Come posso risolvere questo problema?

  2. #2
    Utente di HTML.it L'avatar di nifriz
    Registrato dal
    Jan 2008
    Messaggi
    2,058

    Re: (Delphi 7) Errore In Tedit

    Ciao,
    prova così!

    codice:
    procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char);
    const
      Numbers = '0123456789';
    begin
      if StrScan(Numbers, Key) = nil
       begin
        MessageBeep(20);
       ShowMessage('Errore');   
       key := #0;
      end;
    end;

    [EDIT]
    Ho notato che nel tuto esempio non c'è il ";" dopo ShowMessage, è solo un errore di copia?

  3. #3
    era un errore di copia. ho provato il tuo codice ma mi da sul secondo begin questo errore:
    [Error] Email.pas(525): Missing operator or semicolon

  4. #4
    Anche se sul mio PC non mi da segnalazioni di errori di digitalizzazione sembra che il codice funziona e posto l'alternativa per il testo.
    codice:
    procedure TForm1.PCKeyPress(Sender: TObject; var Key: Char);
    begin
    if not( key in['a'..'z', #10] ) then
    begin
    MessageBeep(20);
    ShowMessage('Digita Solo Carateri');
    key := #0;
    end;
    end;

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 © 2024 vBulletin Solutions, Inc. All rights reserved.