How to achieve loop with textboxinput?

Stellaferox

Active Member
Licensed User
Hi,

I wonder how to achieve a loop with the textboxinput to achieve a number which lies between the acquired numbers.
I want to generate a loop like
DO UNTIL NM<Nr1 AND NM<Nr2 then
NM = textboxNM
LOOP
But this doesnt work. It generates an error. Any ideas?
thank in advance
Marc
 

Stellaferox

Active Member
Licensed User
My fault. I didnt include the "then" but then it still didnt work. I await the next version then....
thnx
Marc
 

Stellaferox

Active Member
Licensed User
Well, the prgram doesn't seem to stop when values other then the wanted ones are put in. The reason the program has a parameter RunFirst = evident. The first time the program runs it takes the default values. The second time input is necessary in the sub Initparameters.
 

Attachments

  • Galton.sbp
    6.6 KB · Views: 216

Erel

B4X founder
Staff member
Licensed User
Longtime User
I'm sorry but I didn't understand the problem.
What is the meaning of:
B4X:
[SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]DO [/COLOR][/SIZE][SIZE=2][SIZE=2][COLOR=#0000ff]UNTIL [/COLOR][/SIZE]NR<=MaxRows [/SIZE][SIZE=2][COLOR=#0000ff]AND [/COLOR][/SIZE][SIZE=2]NR>=MinRows
 NR = txtbxRows.Text
[/SIZE][SIZE=2][COLOR=#0000ff]LOOP[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff][COLOR=#000000]
[/COLOR][/COLOR][/SIZE]
It will cause the program to hang if the values are not in the range.

 

Stellaferox

Active Member
Licensed User
Yes, these three loops should take care of the problem that the input is in the wanted range. That was my question.
Now the program doesnt change the input and certainly not within the wanted boundaries. Or should the UNTIL keyword be after the LOOP word?
 

Cableguy

Expert
Licensed User
Longtime User
Why not use a simple If then else...?

If NR<=MaxRows AND NR>=MinRows then NR = txtbxRows.Text

If the AND bit doesn't work try

If NR<=MaxRows then
If NR>=MinRows then
NR = txtbxRows.Text
end if
end if
 

Cableguy

Expert
Licensed User
Longtime User
Ok from what i understsnd you want to set an interval of values from wich the user must enter a number...Right?

I think that in that case you are testing the wrong variable....


You are testing NR before it is set to txtbxRow...

Try this...

If txtbxRows.Text<=MaxRows AND txtbxRows.Text>=MinRows then NR = txtbxRows.Text

Or more complete:

dim n as int16
n=txtbxRows.text
If n<=MaxRows AND n>=MinRows then NR = txtbxRows.Text
 

Stellaferox

Active Member
Licensed User
Hi Cableguy,

I really DO appreciate your effort but this too doesn't work. Tried the first line myself. Have you tried it in the program? I know you have better things to do but this drives me up the wall........
Marc
 

Cableguy

Expert
Licensed User
Longtime User
Stay tune tonight...
My wife is at work so after dinner i'll give it a serious try....
I havent yet tryed your code, my fault...
 

Stellaferox

Active Member
Licensed User
OK, I'm still on for the next hour returning from a trip abroad so early beds for me tonight. If I am not there anymore I'll catch you tomorrow.
thnx in advance. The sub is called InitParameter.
Marc
 

Cableguy

Expert
Licensed User
Longtime User
Ok, I've found the problem a a partial solution...

If txtbxRows.text<=MaxRows AND txtbxRows.text>=MinRows Then
NR = txtbxRows.Text
Else
msgbox("Rows Must be between 1 and 30")
end if


This is only partial because it dos Not STOP execution.

You should check the validation of the values entered in a seperate sub like the lost focus sub, and if the values were good, then lost focus , if not keep focus, after all values were checed move focus to the run button, then in the run_click ckeck for the run button focus....

just my two cents...nahh.... my 2 euros...lol
 

Stellaferox

Active Member
Licensed User
The other problem is how to stop the program from further execution. this MUST be done by a loop in my view. Returning to the calling sub gives a problem because the first time the sub initparameters is called is before the main page shows. then the parameters must be set by default.
Anyway, we'll give it a try.....
Marc
 

Stellaferox

Active Member
Licensed User
Well, the msgbox pops up but the program continues with the default value. I cannot achieve in getting the right in-out of focus sub to handle the routine.
Marc
 

Cableguy

Expert
Licensed User
Longtime User
another sujestion is to set the runbutton,enable=false while the values are not correct....then turn runbutton.enabled=true...I would also sujest to not pre-load values...
 

Stellaferox

Active Member
Licensed User
The pre-load values are necessary for the first run in which the screen is built up.
I fail to succeed to accomplish your suggestion unfortunately.....
Marc
 
Top