InputBox - ONLY NUMBER AND LIMIT CHARACTERS. IT'S POSSIBLE? - Forum

Forum Navigation
You need to log in to create posts and topics.

InputBox - ONLY NUMBER AND LIMIT CHARACTERS. IT'S POSSIBLE?

ENG:

I NEED AN InputBox THAT GENERATES ME THE VARIABLE WITH ONLY 5 WHOLE NUMBER

DIGITS AND 2 DECIMALS AND WHEN PRESSING ANY KEY THAT IS NOT NUMERICAL IS COMING OUT AN ALERTBOX IT CAN?

ESP:

NECESITO UN InputBox QUE ME GENERE LA VARIABLE CON SOLO 5 DIGITOS NUMERICOS ENTEROS Y 2 DECIMALES Y QUE CUANDO SE PULSE ALGUNA TECLA QUE NO SEA NUMERICA SALGA UN ALERTBOX
¿SE PUEDE?

@neobook

I am not sure what is considered valid and what is invalid ...

Assuming comma (,) is your decimal point ...

123,45 is valid
123,45678 is valid/invalid ? (more than 2 decimal numbers allowed ?)
0,4 is valid/invalid (are 2 decimal numbers required ? e.g. 0,40)
1, is valid/invalid ? (are 2 decimal numbers required ? e.g. 1,00)
12 is valid/invalid ? (are decimal point and 2 decimal numbers required e.g. 12,00)

12345,67 is valid or invalid ? (what is maximum number of integers ?)

Also, do you want to check (throw AlertBox) as each character is typed ... or at the end, when user clicks on some button ?

Puedes usar una máscara de validación para que solo te permita ingresar la cantidad de números que deseas.

Uploaded files:
  • You need to login to have access to uploads.

danito lo tuyo es text entry, y si lees dice InputBox.

La pregunta es sencilla.

Se puede atraves de un inputbox GENERE LA VARIABLE CON SOLO 5 DIGITOS NUMERICOS ENTEROS Y 2 DECIMALES Y QUE CUANDO SE PULSE ALGUNA TECLA QUE NO SEA NUMERICA SALGA UN ALERTBOX.

Necesito que la variable [CANTIDAD2] solo tome 5 digitos mas 2 decimales. y que acepte solo numeros.

Como el Text Entry pero en un imputbox

 

 

Uploaded files:
  • You need to login to have access to uploads.

@neobook

The question is simple.

It can be done through an inputbox GENERATE THE VARIABLE WITH ONLY 5 WHOLE NUMERICAL DIGITS AND 2 DECIMALS AND WHEN PRESSING ANY KEY THAT IS NOT NUMBERED, AN ALERTBOX COMES OUT.

I need the variable [QUANTITY2] to only take 5 digits plus 2 decimals. and accept only numbers.

Like the Text Entry but in an imputbox

Thanks for the image ... I too, was thinking of a TextEntry Box ...

1) Unfortunately, an InputBox does NOT permit interception/user-alert after each keystroke.

2) But you can place the command inside a While/EndWhile loop, check each result from Acceptar button, and if incorrect, throw an AlertBox and not allow exit from the loop ... would that be acceptable ?

3) Also, when you say GENERATE THE VARIABLE WITH ONLY 5 WHOLE NUMERICAL DIGITS AND 2 DECIMALS, did you mean 5 or less numerical digits or exactly 5 digits ?

1-ok

2- tengo que verlo

3. con 7 digitos dos de ellos decmales. ej 00.000,00.

 

@neobook

2) But you can place the command inside a While/EndWhile loop, check each result from Acceptar button, and if incorrect, throw an AlertBox and not allow exit from the loop ... would that be acceptable ?
2- I have to see it

See this code (click event of a button) ...

SetVar "[checkInputResult]" "invalid"

While "[checkInputResult]" "=" "invalid"
   InputBox "Enter Value" "Up to 5 integers and 2 decimal points" "[inputvalue]"
   SetVar "[checkInputValue]" "[inputvalue]"
   ... subroutine will check [checkInputvalue] and report in [checkInputResult]
   GoSub "CheckInput"
   If "[checkInputResult]" "=" "invalid"
      AlertBox "Invalid Input" "Must be something like 12345.67"
   EndIf
   ... if subroutine returns [checkInputResult] as valid, while/endwhile will be exited
EndWhile

AlertBox "Hurray" "[inputvalue] is valid"

For evaluation purposes, the subroutine code just checks for one value ...

:CheckInput
If "[checkInputValue]" "=" "12345.67"
   SetVar "[checkInputResult]" "valid"
Else
   SetVar "[checkInputResult]" "invalid"
Endif
Return

3) Also, when you say GENERATE THE VARIABLE WITH ONLY 5 WHOLE NUMERICAL DIGITS AND 2 DECIMALS, did you mean 5 or less numerical digits or exactly 5 digits ?
3. With 7 digits two of them decmales. ex 00,000.00.

If above design/code is acceptable, I can provide subroutine code ... I understand that 12345.67 is valid, but please confirm if ...

1234,67 (only four integer numbers) is valid/invalid ?
.67 (no integer numbers) is valid/invalid ?

12345.6 (only one decimal number) is valid/invalid ?
12345 or 12345. (no decimal numbers) is valid/invalid ?

0 or .0 or empty is valid/invalid ?

@neobook

Another way to meet your requirement would be to use the CustomWindow facility/command ... if you place a TextEntry Box, and OK and Cancel Buttons within the Custom Window Container, it will look like an InputBox, but will allow you to take advantage of all that the Validation Mask offers (as shown by @danito in a previous post).

 

 

 

neobook has reacted to this post.
neobook