473,513 Members | 2,605 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Form.Show problem

In VB6 I have this in frmMain:

Private sub Button1_Click()
frmSecondOne.Show
me.Hide
End Sub

and then in frmSecondOne:

Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
frmMain.Show
End Sub

How do I do this in VB.NET?
Nov 21 '05 #1
12 2786
How about this? Using ShowDialog to find out when the form is closed.

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim newForm As New frmSecondOne

Me.Hide()
newForm.ShowDialog()
Me.Show()
End Sub

"Kevin" <ke****@cfl.rr.com> wrote in message
news:ae********************************@4ax.com...
In VB6 I have this in frmMain:

Private sub Button1_Click()
frmSecondOne.Show
me.Hide
End Sub

and then in frmSecondOne:

Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
frmMain.Show
End Sub

How do I do this in VB.NET?

Nov 21 '05 #2
No good. I need to show other forms while showing the second form.
Also, how would I reference a textbox or Listbox on frmMain?

VB6:

Text1 = frmMain.Text1

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 21 '05 #3
"Kevin" <ke****@cfl.rr.com> schrieb:
In VB6 I have this in frmMain:

Private sub Button1_Click()
frmSecondOne.Show
me.Hide
End Sub

and then in frmSecondOne:

Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
frmMain.Show
End Sub

How do I do this in VB.NET?


\\\
Public Sub Main()
Dim f As New Form1()
f.Show()
Application.Run()
End Sub
///

In a button:

\\\
Dim f2 As New Form2()
f2.Show()
Me.Close()
///

You can exit the application by calling 'Application.ExitThread'.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Nov 21 '05 #4
In this case you will need to add a module to your application and add the
line:
Public frmMe As Form

On the first form add an onload event like:
Private Sub Form1_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.Load
frmMe = Me
End Sub

For your button add the code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim newForm As New frmSecondOne

Me.Hide()
newForm.Show()
End Sub

Then on the closing event on frmSecondOne:
Private Sub frmSecondOne_Closing(ByVal sender As Object, ByVal e As
System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
frmMe.Show()
End Sub

You will be able to reference the first form from anywhere by using:
frmMe.Text1.Text = "Hello World"

Regards
Scott.

"Kevin Mahoney" <ke****@cfl.rr.com> wrote in message
news:en**************@TK2MSFTNGP09.phx.gbl...
No good. I need to show other forms while showing the second form.
Also, how would I reference a textbox or Listbox on frmMain?

VB6:

Text1 = frmMain.Text1

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 21 '05 #5
Works fine except for referencing the first form. I have a listbox on
the first form I'm trying to reference. I get the error "Listbox1 is
not a member of 'System.Windows.Forms.Form'". What am I doing wrong?

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 21 '05 #6
I found this article very helpful when I was starting to learn:
http://www.devcity.net/Articles/100/multipleforms2.aspx

Nov 21 '05 #7
Just started with .net from vb6 I tried the code Cant Ref Form1 If .net is
totally opp there has to be an easy way to reference the hidden Object
(Form)

"pmclinn" <pe***@mclinn.com> wrote in message
news:11********************@c13g2000cwb.googlegrou ps.com...
I found this article very helpful when I was starting to learn:
http://www.devcity.net/Articles/100/multipleforms2.aspx


Nov 21 '05 #8
I just posted A ? About recalling A hidden Object(Form1) I think Kevin's ?
is the same After Hiding Form1 we want to Show or unhide the same Instance
of the form. Thats what Kevins code would do in vb6.
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:up****************@TK2MSFTNGP10.phx.gbl...
"Kevin" <ke****@cfl.rr.com> schrieb:
In VB6 I have this in frmMain:

Private sub Button1_Click()
frmSecondOne.Show
me.Hide
End Sub

and then in frmSecondOne:

Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
frmMain.Show
End Sub

How do I do this in VB.NET?


\\\
Public Sub Main()
Dim f As New Form1()
f.Show()
Application.Run()
End Sub
///

In a button:

\\\
Dim f2 As New Form2()
f2.Show()
Me.Close()
///

You can exit the application by calling 'Application.ExitThread'.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>


Nov 21 '05 #9

I did what the author of this article did:
http://www.devcity.net/Articles/100/multipleforms2.aspx

Did you try it?
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 21 '05 #10
Kevin I have you answer. This code make Form1 and Form2 work just like in
VB6

I new there had to be a simple way to only have one instance of every form
in your app and be able to effect the form and controls exactly like in vb6.
So I Finally figured out an easy way to do it.

Module Module1

Public WithEvents frm1 As New Form1()

Public WithEvents frm2 As New Form2()

Public jim As String

Public Sub main()

Application.Run(frm1)

End Sub

End Module

__________________________________________________ __________________________
_________

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

frm2.Show()

Me.Hide()

End Sub

_________________"Code in
Form1_____________________________________________ __________________________
_______

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

frm1.Visible = True

End Sub

________________"Code in
Forn2_____________________________________________ __________________________
_____________

"Kevin" <ke****@cfl.rr.com> wrote in message
news:ae********************************@4ax.com...
In VB6 I have this in frmMain:

Private sub Button1_Click()
frmSecondOne.Show
me.Hide
End Sub

and then in frmSecondOne:

Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
frmMain.Show
End Sub

How do I do this in VB.NET?


Nov 21 '05 #11
Didnt have to use the WithEvents key word
"Jim Burns" <Jim@Home> wrote in message
news:to********************@comcast.com...
Kevin I have you answer. This code make Form1 and Form2 work just like in
VB6

I new there had to be a simple way to only have one instance of every form
in your app and be able to effect the form and controls exactly like in vb6. So I Finally figured out an easy way to do it.

Module Module1

Public WithEvents frm1 As New Form1()

Public WithEvents frm2 As New Form2()

Public jim As String

Public Sub main()

Application.Run(frm1)

End Sub

End Module

__________________________________________________ __________________________ _________

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

frm2.Show()

Me.Hide()

End Sub

_________________"Code in
Form1_____________________________________________ __________________________ _______

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

frm1.Visible = True

End Sub

________________"Code in
Forn2_____________________________________________ __________________________ _____________

"Kevin" <ke****@cfl.rr.com> wrote in message
news:ae********************************@4ax.com...
In VB6 I have this in frmMain:

Private sub Button1_Click()
frmSecondOne.Show
me.Hide
End Sub

and then in frmSecondOne:

Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
frmMain.Show
End Sub

How do I do this in VB.NET?



Nov 21 '05 #12
You Dont need the "withevents" key word and I dont know how the jim as
string got there but dont need that as well.
"Jim Burns" <Jim@Home> wrote in message
news:to********************@comcast.com...
Kevin I have you answer. This code make Form1 and Form2 work just like in
VB6

I new there had to be a simple way to only have one instance of every form
in your app and be able to effect the form and controls exactly like in vb6. So I Finally figured out an easy way to do it.

Module Module1

Public WithEvents frm1 As New Form1()

Public WithEvents frm2 As New Form2()

Public jim As String

Public Sub main()

Application.Run(frm1)

End Sub

End Module

__________________________________________________ __________________________ _________

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

frm2.Show()

Me.Hide()

End Sub

_________________"Code in
Form1_____________________________________________ __________________________ _______

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

frm1.Visible = True

End Sub

________________"Code in
Forn2_____________________________________________ __________________________ _____________

"Kevin" <ke****@cfl.rr.com> wrote in message
news:ae********************************@4ax.com...
In VB6 I have this in frmMain:

Private sub Button1_Click()
frmSecondOne.Show
me.Hide
End Sub

and then in frmSecondOne:

Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
frmMain.Show
End Sub

How do I do this in VB.NET?



Nov 21 '05 #13

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
73973
by: genetic.error | last post by:
I'm moving from Vb6 to VB.Net. I have a feeling this has come up before... The VS.Net MSDN file seems to state that the following should work: Form1.Show Form1.Visible = True Form1.Hide...
4
2163
by: Tonya | last post by:
Hi, Does anyone have any example of how i can manage forms in my application?? I want to be able to reference my form instances that are currently open from other forms. why cant i open...
5
3595
by: me | last post by:
I have a Class Library that contains a Form and several helper classes. A thread gets created that performs processing of data behind the scenes and the Form never gets displayed (it is for debug...
11
3462
by: Johnny | last post by:
I'm a rookie at C# and OO so please don't laugh! I have a form (fclsTaxCalculator) that contains a text box (tboxZipCode) containing a zip code. The user can enter a zip code in the text box and...
6
4080
by: nadeem_far | last post by:
Hello All, I am working on a .Net desktop application and I am having problem displaying a form. I am using C# and version 1.1 of the framework. here is how the code looks likes and I will...
8
4395
by: Johnny | last post by:
I'm a rookie at C# and OO so please don't laugh! I have a form (fclsTaxCalculator) that contains a text box (tboxZipCode) containing a zip code. The user can enter a zip code in the text box and...
4
3130
by: Rod Gill | last post by:
Hi, I have a form that when opened in the designer appears of the screen. The form selector can't be dragged (or resized) and if I scroll right and down to centralise it the form simply jumps...
5
3918
by: ortaias | last post by:
I have a form which calls up a second form for purposes of data entry. When closing the data entry form and returning to the main form, things don't work as expected. When I return to the main...
0
1225
by: Miro | last post by:
Something I have run into using VB Express 2005 with mdi forms. I have not been able to re-create this but I'll let out the information on how I came about fixing this. As it cost me about 4...
1
3653
by: =?Utf-8?B?U2FpbXZw?= | last post by:
Hello Marc Gravell and Machin. Good Day. Why your not using an Instance in the form and yet your using a New Form? Im using it because I want to open a single form only. If Im using a New...
0
7260
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7160
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7384
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7537
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
5685
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
3233
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3222
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
799
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
456
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.