Home > Archive > Visual Basic > August 2005 > Newbie: (again) pass event from different form
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Newbie: (again) pass event from different form
|
|
|
| Hi,
I'll try to explain the problem :
I've created an application that its supposed to process some data read from
a file.
So, I have an OpenFile form that open and verifies the data, and stores them
in a public array.
I want to: after i close the OPenFile form to Enable a whole bunch of
controls in the MainForm, so that the user can do the required actions to ,
now, process the validated data.
How can i tell the main form to do this IF the OpenFile closed with valid
data?
Thanx
-steve
| |
| Michael C 2005-08-30, 3:55 am |
| "smith" <jsmith@yahoo.ca> wrote in message
news:AFQQe.4411$2F1.264067@news20.bellglobal.com...
> Hi,
> I'll try to explain the problem :
> I've created an application that its supposed to process some data read
> from a file.
> So, I have an OpenFile form that open and verifies the data, and stores
> them in a public array.
>
> I want to: after i close the OPenFile form to Enable a whole bunch of
> controls in the MainForm, so that the user can do the required actions to
> , now, process the validated data.
>
> How can i tell the main form to do this IF the OpenFile closed with valid
> data?
Store a private boolean on the OpenFile form and pass it out as a property.
Then in your main form do somthing like this:
OpenFileForm.Show vbModel
If OpenFileForm.SomeValue = True then
DoSomething
end if
You don't need the =True bit, I just added it to point out it's a boolean.
Michael
| |
| Larry Serflaten 2005-08-30, 6:55 pm |
|
"smith" <jsmith@yahoo.ca> wrote
> Hi,
> I'll try to explain the problem :
> I've created an application that its supposed to process some data read from
> a file.
> So, I have an OpenFile form that open and verifies the data, and stores them
> in a public array.
>
> I want to: after i close the OPenFile form to Enable a whole bunch of
> controls in the MainForm, so that the user can do the required actions to ,
> now, process the validated data.
>
> How can i tell the main form to do this IF the OpenFile closed with valid
> data?
Since all you want is a single piece of data, you might as well provide a
function in the OpenForm for others to call. The function would show
the form and get the data, returning a value indicating if the data was valid
or not. For an example, paste the following code in to new form. As you'll
see I used the same form, but the functionality is provided through the use
of the GetInput function....
HTH
LFS
Option Explicit
Dim Valid As Boolean
Private Sub Form_Click()
Dim frmOpen As New Form1
Dim result As Boolean
Select Case Forms.Count
Case 1
' Call the OpenForm's function
result = frmOpen.GetInput()
Set frmOpen = Nothing
' Report result
If result Then
MsgBox "You clicked on the form."
Else
MsgBox "You closed the form"
End If
Case 2
' User clicked on the form
Valid = True
Unload Me
End Select
End Sub
Private Sub Form_Load()
Const msg = "CLICK HERE"
AutoRedraw = True
PSet ((ScaleWidth - TextWidth(msg)) \ 2, (ScaleHeight - TextHeight(msg)) \ 2), BackColor
Print msg
End Sub
Public Function GetInput() As Boolean
' Show the form, validate data
Me.Caption = "USER INPUT FORM"
Me.Show vbModal
'Return valid state
GetInput = Valid
End Function
|
|
|
|
|