Return value from Form

Discussion in 'Questions (Windows Mobile)' started by ghislain, Jun 26, 2007.

  1. ghislain

    ghislain New Member Licensed User

    I created a form [say: Selection-form] which will be used several times to select something. How do I stop my program - wait until the Selection-form is completed - and use the result?

    Something like:

    result = SelectionForm.GetSomething
    ' wait until something is selected
    txtResult.text = result

    Anybody know?
    Thanks - Ghislain
  2. BjornF

    BjornF Active Member Licensed User

    The way I would do it is to just use the when you want to to get the information and include an "Ok" and a "Cancel" button on the form:

    Sub btnOk_click
    end sub

    Sub btnCancel_click
    end sub

    But I am sure there are more elegant solutions around :)

    all the best / Björn
  3. RandomCoder

    RandomCoder Well-Known Member Licensed User


    There are many ways to acheive what you want.
    BjornF has suggested a good event based way of doing this.
    You could also use a Do Until/Do While command or If Then to loop back through the code until your value has changed.

    Have you checked out Erel's Input Panel which can be found here
    You might be able to adapt this to fit your needs.

  4. ghislain

    ghislain New Member Licensed User

    Hello again!

    Your solutions seems logical and i have tried it.
    But - as soon as you call the program continues and the return value from btnClick_OK will never be captured..

    Thanks. I hope i will find a solution which works with forms in the future. But the panel will do the trick for the time being..
    Thinking about it - it won't work. The input-panel example doesn't return a value either..

    I guess a while-wend loop is the only option. It seems quite processor intense to me. I hope there is a better solution. It should be possible - eg: calendar-control & open-dialog.

  5. Erel

    Erel Administrator Staff Member Licensed User

    I don't recommend you to use a waiting loop.
    A better approach will be similar to BjornF solution:
    Sub Sub1
    'the dialog form
    End Sub

    Sub frmOptions_Close
     result = textbox1.text
    End Sub

    Sub Sub2
    'Continue your program
    End Sub
  6. joedoe77

    joedoe77 New Member

    What we need is to add modal/modeless to the Show method of the form, so:

    Form2.Show 0 will work as ususal (Form2 shows but the code continues after to executre after Form2.Show)


    Form2.Show 1 will show Form2 and waits until Form2 is closed (btw: how about a "REAL" close?)
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice