|
-
Oct 24th, 2003, 11:36 AM
#1
Thread Starter
Addicted Member
Sub Main()
Public Sub Main()
Dim frm As New frmMDI
frm.Show()
End Sub
I used the above code in module.
In VB it opens the MDI and stays.
In .Net it doesn't open and stay. Application terminates immediately after doing some process.
Pls help.
-
Oct 24th, 2003, 11:43 AM
#2
Yes Show doesn't hold the thread open you can either use ShowDialog or Application.Run(New frmMDI).
-
Oct 24th, 2003, 12:39 PM
#3
Thread Starter
Addicted Member
Thanks. It worked.
How do I restrict a form to be opened multiple times.
-
Oct 24th, 2003, 12:47 PM
#4
'Restrict it to open multiple times', What do you mean?
-
Oct 24th, 2003, 12:51 PM
#5
Thread Starter
Addicted Member
Dim frm As New Form1
frm.MdiParent = Me
frm.Show()
If I use the above, it opens the form every time I call. But I want it to check whether the form is already open.
I don't want multiple instances of same Form.
-
Oct 24th, 2003, 12:52 PM
#6
Fanatic Member
Do you mean restrict a form to only one instance?
-
Oct 24th, 2003, 12:55 PM
#7
Thread Starter
Addicted Member
-
Oct 24th, 2003, 01:01 PM
#8
Single instance of your app or just that form?
If you mean form then this should get you started: http://www.vbforums.com/showthread.p...hreadid=126418
-
Oct 24th, 2003, 01:02 PM
#9
Fanatic Member
Then you could do something like create the for variable a global (dim myFrm as Form1) and then before you create it when needed, you can check to see if myFrm = Nothing. If it is then go ahead and create the one instance. If <> Nothing then either close it and re-open it, do nothing, or set focus to the instance already in existence.
VB Code:
Dim myFrm As Form1 'Make this a class variable
If myFrm Is Nothing Then
'No instance of the form yet
myFrm = New Form1
myFrm.Show() 'or show dialog
Else
'Instance already exists so take appropriate action here
End If
-
Oct 24th, 2003, 01:03 PM
#10
Fanatic Member
Oh, MDI - the link posted by Edneeis will be of more use then
-
Oct 24th, 2003, 01:09 PM
#11
Thread Starter
Addicted Member
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
|