Dialog Box alongwith Form

Reply

Join Date: Jun 2003
Posts: 313
Reputation: red_evolve is on a distinguished road 
Solved Threads: 0
red_evolve's Avatar
red_evolve red_evolve is offline Offline
Posting Whiz

Dialog Box alongwith Form

 
0
  #1
Jun 29th, 2004
Greetings.
I have a form loaded and in this form, I have a listbox plus a button.
When the button is clicked, a dialog box will appear alongside with the form.
In the dialog box, there is a combo box, in which the user must select something from.
Once the OKbutton is clicked, the value that is selected in the dialog box would be displayed in the form's listbox.
After that, this process can go on repeatedly such that, if I'd like to add 3 new values, I'd activate the dialog box 3 times.

My problem is, where can I place my function call to get the values from the dialog box. Initially, I placed it in the Form_Paint() function which is totally wrong, because the value duplicates everytime i move the form/minimize&maximize it.
After that, I placed it in Form_Activate() function & Form_GotFocus & both cannot work.
Please advice.
Reply With Quote Quick reply to this message  
Join Date: Jun 2004
Posts: 173
Reputation: BinaryMayhem is an unknown quantity at this point 
Solved Threads: 9
BinaryMayhem BinaryMayhem is offline Offline
Unverified User

Re: Dialog Box alongwith Form

 
0
  #2
Jun 29th, 2004
when you call your second form do.
formblah.show vbmodal

then call your function right after that statment.

vbmodal will hold exectuion of the parent window while the child window is open. This is why you can retrieve the value as the next statment in your code.
Reply With Quote Quick reply to this message  
Join Date: Jun 2003
Posts: 313
Reputation: red_evolve is on a distinguished road 
Solved Threads: 0
red_evolve's Avatar
red_evolve red_evolve is offline Offline
Posting Whiz

Re: Dialog Box alongwith Form

 
0
  #3
Jun 29th, 2004
Greetings.
Thanks for the input.
Hey, it works! Hooray! Thanks.
Reply With Quote Quick reply to this message  
Join Date: Jun 2004
Posts: 173
Reputation: BinaryMayhem is an unknown quantity at this point 
Solved Threads: 9
BinaryMayhem BinaryMayhem is offline Offline
Unverified User

Re: Dialog Box alongwith Form

 
0
  #4
Jun 29th, 2004
Glad to be of assistance :p
Reply With Quote Quick reply to this message  
Join Date: Jun 2003
Posts: 313
Reputation: red_evolve is on a distinguished road 
Solved Threads: 0
red_evolve's Avatar
red_evolve red_evolve is offline Offline
Posting Whiz

Re: Dialog Box alongwith Form

 
0
  #5
Jun 29th, 2004
Greetings.
You are indeed of great assistance.
By the way, regarding the Private Sub Form_Activate(), is it true that it is better to store initializations there instead of Private Sub Form_Load()?
I remember I've read somewhere that it is more efficient to store into Form_Activate().
What's the difference?

I'm trying to solve this problem - passing data between 2 forms. The 2nd Form has to take a value stored in a String from the 1st Form.
I have made the String variable in the 1st Form as Public. At the start of execution, it works fine. When I press 'Back' on the 2nd Form, I go to the 1st Form. There I insert a different value & when I click to go on to the 2nd Form, it takes the value from the previous value. At the 3rd try, it takes the value that I have inserted during the 2nd try as if it is slowed down by 1 step. LOL. I can't figure out which is wrong.
Is it because of the Load form2 & Unload form1 sequence of execution?
Please advise.
Reply With Quote Quick reply to this message  
Join Date: Jun 2004
Posts: 173
Reputation: BinaryMayhem is an unknown quantity at this point 
Solved Threads: 9
BinaryMayhem BinaryMayhem is offline Offline
Unverified User

Re: Dialog Box alongwith Form

 
0
  #6
Jul 1st, 2004
#1: the only diffrence between the 2 is form load, gets called every time you call Load formblah, while Form_Activate gets called every time you do formblah.show. that's the only diffrence.

#2 create a public function in a module, also if you wish to pass data between the 2 create the public variables you need outside the fucntion. then have the function call the second window formblah.show, vbmodal. right before you exit this window make sure you dump any information you want shared into the public variables you have created. when control is passed back to the module you then make your function return the value of the public variables!
Reply With Quote Quick reply to this message  
Join Date: Jun 2003
Posts: 313
Reputation: red_evolve is on a distinguished road 
Solved Threads: 0
red_evolve's Avatar
red_evolve red_evolve is offline Offline
Posting Whiz

Re: Dialog Box alongwith Form

 
0
  #7
Jul 1st, 2004
Greetings.
#1 : Got what you meant. Thanks.
#2 : Not sure if I fully understand. But, I'll give it a try and return with questions if I'm stuck.
Thanks a lot.
Reply With Quote Quick reply to this message  
Join Date: Jun 2004
Posts: 173
Reputation: BinaryMayhem is an unknown quantity at this point 
Solved Threads: 9
BinaryMayhem BinaryMayhem is offline Offline
Unverified User

Re: Dialog Box alongwith Form

 
0
  #8
Jul 1st, 2004
haha, I didn't think so... its really late for me, and my mind is half shutoff. (2:35am) Ill repost again tom with an example and explain it better.... goodnight!
Reply With Quote Quick reply to this message  
Join Date: Jun 2003
Posts: 313
Reputation: red_evolve is on a distinguished road 
Solved Threads: 0
red_evolve's Avatar
red_evolve red_evolve is offline Offline
Posting Whiz

Re: Dialog Box alongwith Form

 
0
  #9
Jul 1st, 2004
Greetings.
Woah, it's really late, dude. Good nite!
Thanks for the effort. Looking forward to gain something from your lecture tomorrow. :-)
Reply With Quote Quick reply to this message  
Join Date: Jun 2003
Posts: 313
Reputation: red_evolve is on a distinguished road 
Solved Threads: 0
red_evolve's Avatar
red_evolve red_evolve is offline Offline
Posting Whiz

Re: Dialog Box alongwith Form

 
0
  #10
Jul 16th, 2004
Greetings.
Bringing back an old topic.
But not dialog box this time around.
Same problem: passing variables between forms.
Issue: Form Load & Unload.
Previously, without proper testing of each and every cases, the output was like what I have expected, so I thought I would have no problem.

[1] Again, on the arrangement of Load Form1 vs. Unload Form2
Initially, I thought it doesn't matter but not until I found that it actually matters!
I realise that when I put Unload Form1 before Load Form2, I would not be able to
use the Public variables in Form1. And so, I placed Load Form2 before Unload
Form1.

The problem arises here when I did step [1]. I load Form3 from Form2. I deem that the error occurs because although in Form2, I have Load Form3 followed by Unload Form2, when Form3 is showed Form1 & Form2 is still loaded in the memory because everything goes in a sequence:

Load Form1
Load Form2
Load Form3
Unload Form3
Unload Form2
Unload Form1

Actually, the real scenario goes like this:
Forms: Form1, Form2, Form3.
Form3 can be loaded by Form1 and Form2.
Therefore, in Form3, I'd like to code for different activities for different form that loaded Form3. How can I achieve that?
I did ->
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. ' Form3
  2. Private Sub Form_Load()
  3. If Form1.cmdGo Then
  4. ' Do something
  5. ElseIf Form2.cmdGo Then
  6. ' Do something
  7. End If
  8. End Sub
However, I realised later that this is not right, because when I clicked on the navigation menu on the left hand side of the form to go to Form2, then Form3, it works fine. Continue with clicking on Form1, then Form3 -> output was not as expected, because, it doesn't go to the ElseIf all the time when at the beginning Form1.cmdGo is evaluated True. :-|
Sorry, I know it's a bit confusing there, but I hope someone would understand my problem.
"Study the past if you would define the future" - Confucius
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the Visual Basic 4 / 5 / 6 Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC