-
May 30th, 2013, 09:37 PM
#1
How many test form is open ?
I suppose there are many programs of the form, I can determine how much the order form is opened and the name of the form is not open? Who can share me with example, thanks
-
May 31st, 2013, 03:51 AM
#2
Re: How many test form is open ?
Code:
Private Sub Command3_Click()
Dim NumberOfForms As Integer 'Variable to hold number of open forms
NumberOfForms = Forms.Count 'Count all open forms
MsgBox NumberOfForms 'Display variable
Dim intCounter As Integer
For Each Form In Forms 'Loop through Forms collection
MsgBox Forms(intCounter).Name 'Display each open form's name
intCounter = intCounter + 1
Next
End Sub
-
June 7th, 2013, 01:23 AM
#3
Re: How many test form is open ?
Originally Posted by HanneSThEGreaT
Code:
Private Sub Command3_Click()
Dim NumberOfForms As Integer 'Variable to hold number of open forms
NumberOfForms = Forms.Count 'Count all open forms
MsgBox NumberOfForms 'Display variable
Dim intCounter As Integer
For Each Form In Forms 'Loop through Forms collection
MsgBox Forms(intCounter).Name 'Display each open form's name
intCounter = intCounter + 1
Next
End Sub
1. form that is open can have a number of these?
2. closed form series open with error
For Each frm In Forms
If frm.Name <> Me.Name Then
If frm.MDIChild = True Then
MDIMainForm.RemoveChild frm.Name ' Error here
End If
End If
Next
Set frm = Nothing
-
June 7th, 2013, 01:26 AM
#4
Re: How many test form is open ?
I don't understand your last question. Mind rephrasing it a bit, please
-
June 20th, 2013, 01:10 AM
#5
Re: How many test form is open ?
Originally Posted by HanneSThEGreaT
I don't understand your last question. Mind rephrasing it a bit, please
The my program has very many forms, but there are 2 main types MDIForm and FormChild. when I open many FormChild into MDIForm, instead I close each FormChild. I want close many FormChild same time instead closing FormChild one by one. Do you understand ?
-
June 10th, 2013, 01:09 AM
#6
Re: How many test form is open ?
1. Have i want to order of forms openning ?
2. I want to close all form openning but not and warning error
For Each frm In Forms
If frm.Name <> Me.Name Then
If frm.MDIChild = True Then
MDIMainForm.RemoveChild frm.Name ' Error here
End If
End If
Next
Set frm = Nothing
-
June 10th, 2013, 02:08 AM
#7
Re: How many test form is open ?
What is the error and what is it you are trying to do?
Always use [code][/code] tags when posting code.
-
June 21st, 2013, 11:04 PM
#8
Re: How many test form is open ?
Yes. But, VB6 can't do that. You'd have to close the MDIForm that contained the Children.
-
June 22nd, 2013, 04:52 PM
#9
Re: How many test form is open ?
I have never saw this used
Code:
MDIMainForm.RemoveChild frm.Name ' Error here
If I was wanting to unload the children of a mdi form I would use the Unload method
Always use [code][/code] tags when posting code.
-
August 11th, 2013, 02:08 AM
#10
Re: How many test form is open ?
Originally Posted by DataMiser
I have never saw this used
Code:
MDIMainForm.RemoveChild frm.Name ' Error here
If I was wanting to unload the children of a mdi form I would use the Unload method
if I use Unload the following Unload I have must to put the correct name of FormChild. eg MDIForm have Form1, Form2, ... Formn:
unload Form1
unload Form2
...
unload Formn
Now, I want to replace the code above with:
Dim frm As Form
' Close many FormRemoveChild
For Each frm In Forms
If Me.Name <> frm.Name Then ' Me.Name is MDIForm and frm.Name is Form1, Form2, ...., Formn
Unload frm.Name ' Error here
End If
Next
Set frm = Nothing
What should I do ?
Last edited by dongtrien; August 11th, 2013 at 02:11 AM.
-
August 11th, 2013, 02:20 AM
#11
Re: How many test form is open ?
It would help if you would tell us what the error message is rather than just saying error here.
At any rate the problem is that you are using unload incorrectly
it should be
when you add the .name you are telling it to unload the name property of the form which is a string and of course that is not valid resulting in a type mismatch
Example:
Create a new project with 2 forms form1 and form2
Add a button to form 1 and use the default name of command1
paste this code in form1 code window replacing any that is there already
Code:
Option Explicit
Private Sub Command1_Click()
Dim frm As Form
For Each frm In Forms
If frm.Name <> Me.Name Then
Unload frm
End If
Next
End Sub
Private Sub Form_Load()
Dim x As Integer
Dim frm As Form
For x = 1 To 10
Set frm = New Form2
frm.Show
Next
End Sub
run the program then click the button
it should create 10 copies of form 2 and then close them when you click the button leaving form 1 in tact
Last edited by DataMiser; August 11th, 2013 at 02:25 AM.
Always use [code][/code] tags when posting code.
-
August 15th, 2013, 02:53 AM
#12
Re: How many test form is open ?
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
|