Errore End application


C'è qualche pezzo di codice che evita " l'errore " end application quando in una casella di testo non si scrive niente. L'app è una semplice moltiplicazione

This code should run at screen initialization and in the textbox changed events

Button1.Enabled = and(
  Is a number(textbox1.text)
  Is a number (textbox2.text)
)





Dici cosi?

Si lo so è gia settato in quel modo, ma sei scrivo nella casella di testo un numero e nella seconda la lascio vuota e premo il pulsante,vorrei evitare quella errore end application

No.

I am on my phone so I can not make blocks.

Look in the math blocks for the block that tests for numbers.

blocks
is_a_number.aia (2.2 KB)
sample run

Notice how the '+' button gets enabled and disabled as I type.

P.S. I used a procedure to avoid duplicating code.

funziona anche quando la casella di testo rimane vuota?

Find the solution here

AIA :
Textbox.aia (2.2 KB)

Screenshots :



Blocks :

era quello che serviva grazie :heart:

If you got the solution, mark it to help others.
If not, then please explain what you wanted to do with it. :blush:

Yes.

There are two different philosophies in these two different solutions.

  • One philosophy is to not let an error happen by disabling the + button until all input is good. I see that on web sites asking for input, where the Submit button won't work until all the required fields are good.

  • The other is to leave the + button enabled, but pop up a message if an input is bad.

I guess it's a matter of personal choice.

P.S. Try this test data: ',' * ','

si hai ragione proverò tutte e due e vedrò qual è meglio

Why only this data may I know for my knowledge?
What is the speciality in this data?

I was trying to use a loophole in the numeric textbox setting that accepts decimal points in numbers, and catch it before any digits were entered. That would have the text box nonblank but not a number,

But I got the loophole wrong, and it did not exist in the first place. I could not fool the numeric textbox into momentarily displaying a non-number.

I did not try a minus sign.

P.S. I just tried entering '-' into two numeric textboxes, and that sample distinguishes between blank checking and is-number checking.

Numeric textboxes can be made to allow non-number non-blank values, if you catch them just right.

1 Like

C'è invece qualcosa che permette di inserire solo numeri interi nella casella di testo?
Oppure mi servirebbe limitare l'inserimento del punto, come virgola

In the Textbox Changed event, test if it contains the comma you hate. If so, use the text replace block to replace the comma with an empty text block.

Do this also for decimal points.

C'è qualche blocco che permette di inserire solo numeri interi nella casella di testo?
Altrimenti servirebbe limitare l'inserimento del punto, come virgola

This is the upgradation of your previous helped aia file :

Textbox.aia (3.7 KB)

Blocks That shows how to convert the numbers into whole number.

1 Like

Try this, works for me, by setting numbersOnly, commas are not accepted, we only have to remove decimal points and minus signs.

1 Like