-
February 12th, 2007, 12:06 PM
#1
How to know which button pressed when a form closes
Forgive me I am sure this is really easy, but I do not know VB at all, and I got stuck with a program.
I am showing a form by calling this...
Form1.Show 1
This opens another "window" which collects data from the user, then the user can either hit the OK or CANCEL button. How does the calling function know what button the user pressed?
I assume that you could do something like this...
ButtonPressed = Form1.Show 1
but you can not.
Can any one help me answer this easy question?
Thanks a lot, I appricate it.
--------------------------------------------
Whats in Iowa.... Corn and Code...
-
February 12th, 2007, 12:19 PM
#2
Re: How to know which button pressed when a form closes
-
February 12th, 2007, 01:05 PM
#3
Re: How to know which button pressed when a form closes
Well it should be easy my friend, but I neither understood the question nor the reply post
-
February 12th, 2007, 03:30 PM
#4
Re: How to know which button pressed when a form closes
you need to wrap the opening and closing of the form in a Public function within it.
e.g. in Form1, I have:
Code:
Private lRet As Long
Public Function ShowForm() As Long
Me.Show vbModal
ShowForm = lRet
Unload Me
End Function
Private Sub Command1_Click()
lRet = 1
Me.Hide
End Sub
Private Sub Command2_Click()
lRet = 2
Me.Hide
End Sub
in the calling form I have:
Code:
Private Sub Command1_Click()
Debug.Print Form2.ShowForm
End Sub
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
|