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
The way I would do it is to just use the selectionform.show when you want to to get the information and include an "Ok" and a "Cancel" button on the form:
Sub btnOk_click
result=txtSelection.text
selectionform.close
end sub
Sub btnCancel_click
selectionform.close
end sub
But I am sure there are more elegant solutions around
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.
BjornF,
Your solutions seems logical and i have tried it.
But - as soon as you call formSelection.show the program continues and the return value from btnClick_OK will never be captured..
RandomCoder
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..
Bummer!
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.
I don't recommend you to use a waiting loop.
A better approach will be similar to BjornF solution:
B4X:
Sub Sub1
...
frmOptions.Show 'the dialog form
End Sub
Sub frmOptions_Close
result = textbox1.text
Sub2
End Sub
Sub Sub2
... 'Continue your program
End Sub