How to achieve loop with textboxinput?

Discussion in 'Questions (Windows Mobile)' started by Stellaferox, May 6, 2007.

  1. Stellaferox

    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
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    There should be no "then" in a Do Until / Do While loop:
    In the next version, you will need to add .Text to get the TextBox text.
    Code:
    DO UNTIL NM<Nr1 AND NM<Nr2
    NM = textboxNM.Text
    LOOP
     
  3. Stellaferox

    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
     
  4. Erel

    Erel Administrator Staff Member Licensed User

    The code above should work in this version without any problems.
    What doesn't work for you?
     
  5. Stellaferox

    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.
     

    Attached Files:

  6. Erel

    Erel Administrator Staff Member Licensed User

    I'm sorry but I didn't understand the problem.
    What is the meaning of:
    Code:
    [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.

     
  7. Stellaferox

    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?
     
  8. Cableguy

    Cableguy Expert Licensed 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
     
  9. Stellaferox

    Stellaferox Active Member Licensed User

    Nope, doesn't work either. The program runs with the wrong parameters.
     
  10. Cableguy

    Cableguy Expert Licensed 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
     
  11. Stellaferox

    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
     
  12. Cableguy

    Cableguy Expert Licensed 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...
     
  13. Stellaferox

    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
     
  14. Cableguy

    Cableguy Expert Licensed 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
     
  15. Stellaferox

    Stellaferox Active Member Licensed User

    Hey cableguy, the focus-idea sounds good to me! I will try this tomorrow and let you know.
    Marc
     
  16. Stellaferox

    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
     
  17. Erel

    Erel Administrator Staff Member Licensed User

    Why not something simple like:
    Code:
    If txtbxRows.text<=MaxRows AND txtbxRows.text>=MinRows Then
    NR = txtbxRows.Text
    Else
    msgbox("Rows Must be between 1 and 30")
    RETURN
    end if
     
  18. Stellaferox

    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
     
  19. Cableguy

    Cableguy Expert Licensed 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...
     
  20. Stellaferox

    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
     
Loading...