|
-
Nov 1st, 2001, 02:57 PM
#1
Thread Starter
New Member
Make User Control Show and Terminate itself
I want to have a function in a user control to:
1. initialize/show the user control
2. calculate the function value based on user inputs, and
3. terminate the user control and pass the value to the main program from where the usercontrol.function is called.
How is this possible?
-
Nov 2nd, 2001, 10:25 AM
#2
Hyperactive Member
You can't terminate a user control, nor you can initialize it. But you can place it on a modal form, and show it when necessary. That will automatically cuase the initialization of the control. And when you unload the form, the control is terminated.
Abu Haider
____________________________
100% Data Validation for the MS DataGrid Control. Plus Support for Custom and Foreign Lists, DatePicker and much more...
The DataGridEnhancer
I often point to a place where the problem has been discussed, instead of giving you the code that solves it. This is for good, may be you will understand some day...
-
Nov 2nd, 2001, 01:03 PM
#3
Thread Starter
New Member
Ok. I have a control in the form that generates an array based on user interaction. Then the user closes the form. How do I pass that array to the calling form before the object is destroyed?
-
Nov 2nd, 2001, 01:17 PM
#4
Hyperactive Member
functions can return array in VB6, or you could also use a collection.
It depends on how you are implementing that thing.
Abu Haider
____________________________
100% Data Validation for the MS DataGrid Control. Plus Support for Custom and Foreign Lists, DatePicker and much more...
The DataGridEnhancer
I often point to a place where the problem has been discussed, instead of giving you the code that solves it. This is for good, may be you will understand some day...
-
Nov 2nd, 2001, 01:48 PM
#5
Thread Starter
New Member
Here is what I have:
Option Explicit
Private arrayList As Variant
Private Sub Command1_Click() ' This code is in Form1
'Here I show the Form2 that generates an array of strings (a selected file list for example)
Form2.Show vbModal
'After I show the form I can not get the data cause user destroys the object when he is finished making selections
arrayList = Form2.ctlMyOpenFile1.arrayData
End Sub
-
Nov 2nd, 2001, 02:21 PM
#6
Hyperactive Member
two ways..
First is. don't let the user destroy (unload) the second Form. You hide it, hiding will cause the Show method return to the first Form. The second Form remains in memory, and therefore you can access the control.
After you access the array, unload the second Form from the first one.
Will that do for you?
Abu Haider
____________________________
100% Data Validation for the MS DataGrid Control. Plus Support for Custom and Foreign Lists, DatePicker and much more...
The DataGridEnhancer
I often point to a place where the problem has been discussed, instead of giving you the code that solves it. This is for good, may be you will understand some day...
-
Nov 2nd, 2001, 02:49 PM
#7
You might also consider having a BAS module that has all of the data you need to pass back & forth declared Public.
This isn't as neat, but data never disappears because you neglected to extract the data before the form was unloaded.
-
Nov 7th, 2001, 01:51 PM
#8
Thread Starter
New Member
Thanks to all that replied. For info I am sharing what I ended up doing.
- Loaded the control in a form.
- Created an event in the form and raised it when the form unloads.
- As the event is visible in the calling form I put code there to read the arrayData just before the form and control are destroyed.
Thanks again for pointing in the right direction. I thought I could make a control itself appear and disapear and was trying to put the event in the control itself. That did not work.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|