Autore Topic: textbox numerica  (Letto 1104 volte)

Offline neo571

  • Gamberetto
  • *
  • Post: 11
    • Mostra profilo
    • http://fddf
textbox numerica
« il: 08 Settembre 2008, 13:19:11 »
Come posso fare per creare una textbox numerica ovvero che accetti solo numeri e non lettere ?

Offline Ceskho

  • Amministratore
  • Senatore Gambero
  • *****
  • Post: 3.778
  • Vi Veri Veniversum Vivus Vici
    • Mostra profilo
    • Pagina Personale
Re: textbox numerica
« Risposta #1 il: 08 Settembre 2008, 14:51:06 »
Potresti usare una ValueBox che è fatta apposta....

Offline giulio

  • Maestro Gambero
  • ****
  • Post: 280
    • Mostra profilo
Re: textbox numerica
« Risposta #2 il: 08 Settembre 2008, 22:23:26 »
e sì ma finisce il divertimento...

due esempi:

Codice: [Seleziona]

PUBLIC SUB TextBox1_change()
 
  DIM n AS Integer
  DIM char, newtext AS String
 
  FOR n = 1 TO Len(LAST.text)
   
    char = Mid$(LAST.text, n, 1)
   
    IF char LIKE "[0-9]" THEN
      newtext = newtext & Mid$(LAST.text, n, 1)    
    ENDIF
   
  NEXT
 
  LAST.text = newtext
       
       
END




Codice: [Seleziona]

PUBLIC SUB TextBox1_KeyPress()

  SELECT Key.code
    CASE Key.Enter, Key.BackSpace, Key.Delete, Key.Left,
         Key.Right, Key.Return, Key.space
      RETURN
  END SELECT
 
  IF Key.Text LIKE "[0-9]" THEN
    RETURN
  ELSE
    STOP EVENT
  ENDIF
   
END

Offline Ceskho

  • Amministratore
  • Senatore Gambero
  • *****
  • Post: 3.778
  • Vi Veri Veniversum Vivus Vici
    • Mostra profilo
    • Pagina Personale
Re: textbox numerica
« Risposta #3 il: 08 Settembre 2008, 22:35:31 »
capisco il vostro entusiasmo ma io preferisco risparmiare quante più righe di codice possibile e questo per me è uno "spreco"....eheheheheheh.... :-P

Offline neo571

  • Gamberetto
  • *
  • Post: 11
    • Mostra profilo
    • http://fddf
Re: textbox numerica
« Risposta #4 il: 10 Settembre 2008, 11:51:06 »
Grazie