Jay1b Posted September 29, 2004 Posted September 29, 2004 (edited) Hi. Could someone please look at the below for me? I have rewritten it from my actual code to make it a better example of what i am trying to do. 'This is called every second, I will nearly always be 1 For i to 100 If i <> 1 Then Dim OtherForm As New FrmOtherForm OtherForm.Text = Str(i) OtherForm.Show() 'If returned value then do something, else do something else ENDIF Next i I would like to somehow return a value from each occurence of OtherForm and not proceed with the loop until the other form has been closed - and the value returned. I certainly want to stop multiple forms being launched simultaneously. Could someone please point me in the right direction? Thanks. Edited September 29, 2004 by Jay1b Quote
Administrators PlausiblyDamp Posted September 29, 2004 Administrators Posted September 29, 2004 You could use ShowDialog rather than Show. I've got to ask though - are you really planning on displaying the same form 100 times to a user? That would drive me up the wall if I was the end user. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Jay1b Posted September 29, 2004 Author Posted September 29, 2004 Thanks yet again. The ShowDialog works beautifully for returning a value, but it doesnt stop the code from continueing until a value has been returned. So i still get multiple forms appearing. Imagine a firewall, when you first install it you get unindated with 'Do you wish to allow ****.exe to access the internet?' screens. Then after its been installed a few weeks you barely get any of these screens, this will work on the same principle. Quote
Administrators PlausiblyDamp Posted September 29, 2004 Administrators Posted September 29, 2004 Is that the exact code you are using to display the forms? If so the ShowDialog should block further processing until the form has been dismissed. It may be worth showing your actual code to see if you are doing anything that might cause problems. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Jay1b Posted September 29, 2004 Author Posted September 29, 2004 Argh..... Just had a thought, this piece of code is being called every second by the timer. So the ShowDialog is blocking the rest of the code, but the timer is creating a new instance of that code every second. I've checked this and can confirm thats whats happening :) Thanks. Quote
*Experts* Nerseus Posted September 29, 2004 *Experts* Posted September 29, 2004 I didn't see a question in that last post... As P said, why not tell us what you're trying to do rather than what you're doing (and it sure seems odd, whatever it is). -ner Quote "I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
Jay1b Posted September 29, 2004 Author Posted September 29, 2004 There wasnt suppose to be a question. The post was aimed purely at saying thank you. :D Yes it is rather different, its something i am seriously thinking about releasing, or selling to someone who could write it properly and let them sell it :) Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.