Erel, hello,
It appears that B4XPlusMinus does not have a means to set a default value. Or, I have not found the class member or method to set a default.
In the project I am working on user is to set values (say Day, Month, Year).
This is not to get the current but some arbitrary date the user has to supply.
What I found is that, if the user does not have to change a value (say day happens to be the first day of a month so, doesn't have to press the control) the value floats at Zero (this
would be Zero if not directly changed). This mean that you get an error down the road when you try to so something with the values.
For instance :
The Parser complains because of the zero value (including in the 'year' slot). Obviously, if one did something bizarre like a division using one of those (date) numbers, it will bomb. But selections can be wide ranging so a division is not improbable. Perhaps a reasonable simple example would be : if one has to select the pH value in a water quality test, the default could be set at 7 with the range being set at 4 -> 10 with an increment of whatever. One assumes, then, that 7 would be the value that appears between the arrows of the control, so a change like this obviously will mean a bit more coding on your side (sorry).
Incidentally, if one presses the control to get a 2 and then go back to a 1, this is OK later on (obviously).
As said above, this is because there isn't a way to set a default (only the range,
and the increment.
Because "1" is the initial value of the range, this does not translate into a default value.
Obviously, the wish here, if I am not missing something, is for an extra parameter to SetNumericRange that would set a default value, therefore elimination of traps to be set in other parts of the project code. Not sure if one would then have to do anything in the Click event, but it seems unlikely.
Thanks, stay indoors don't starve, even unused toilet paper might have some nutrition. . . .
Thanks
It appears that B4XPlusMinus does not have a means to set a default value. Or, I have not found the class member or method to set a default.
In the project I am working on user is to set values (say Day, Month, Year).
This is not to get the current but some arbitrary date the user has to supply.
What I found is that, if the user does not have to change a value (say day happens to be the first day of a month so, doesn't have to press the control) the value floats at Zero (this
B4X:
[B]startday [/B]= SdayB4XPlusMinus1.SelectedValue
For instance :
B4X:
startdate = DateTime.DateParse(startmonth & "/" & startday & "/" & startyear) ' convert entered date into ticks
The Parser complains because of the zero value (including in the 'year' slot). Obviously, if one did something bizarre like a division using one of those (date) numbers, it will bomb. But selections can be wide ranging so a division is not improbable. Perhaps a reasonable simple example would be : if one has to select the pH value in a water quality test, the default could be set at 7 with the range being set at 4 -> 10 with an increment of whatever. One assumes, then, that 7 would be the value that appears between the arrows of the control, so a change like this obviously will mean a bit more coding on your side (sorry).
Incidentally, if one presses the control to get a 2 and then go back to a 1, this is OK later on (obviously).
As said above, this is because there isn't a way to set a default (only the range,
B4X:
SdayB4XPlusMinus1.SetNumericRange(1, 31, 1)
Because "1" is the initial value of the range, this does not translate into a default value.
Obviously, the wish here, if I am not missing something, is for an extra parameter to SetNumericRange that would set a default value, therefore elimination of traps to be set in other parts of the project code. Not sure if one would then have to do anything in the Click event, but it seems unlikely.
Thanks, stay indoors don't starve, even unused toilet paper might have some nutrition. . . .
Thanks