Hi Group,
Sorry I know this has probably been asked loads of time, and sorry also for
my stupidity (Im a Newbie!) but ......
I have a Main Form with a button on it. When a user Clicks on the Button I
want it to Open Form2 and Close Form one but for the life of me I carn`t
find out where to do it.
I have the following Code to bring up a Form
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim Form1 As New Form1()
Form1.Show()
End Sub
I`ve Also Tryed
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim Form1 As New Form1()
Form1.Show()
Me.Close
End Sub
But this opens up Form2 and close`s it again straight Away.
I`ve also tryed Form1.ShowDialog() but that dosn`t seem to help either?
Any bosy got any suggestions on Links?
Ta
Si 11 898
* "Newbie!" <s_************@yahoo.co.uk> scripsit: Sorry I know this has probably been asked loads of time, and sorry also for my stupidity (Im a Newbie!) but ......
I have a Main Form with a button on it. When a user Clicks on the Button I want it to Open Form2 and Close Form one but for the life of me I carn`t find out where to do it.
<http://www.google.com/groups?selm=u%23xQOutWDHA.2100%40TK2MSFTNGP11.phx. gbl>
--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Hi thanks for you help,
I`ve tryed that but it dosn`t work, here goes - I have a 2 Forms (Form1 &
Form 2) on Form 1. I have a Button (Button1) in Button1`s code as follows
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim f2 as Form2
f2 = New Form2()
f2.Show()
Me.Close()
End Sub
How ever when i Click on the Button, Form2 loads then closes it`s self
stright away, If i take out the Me.Close it stays open but so does Form1
How do I get Form1 to Close When Form2 is loaded?
Do I need any Code else where other than Button1_Click?
Ta
Si
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:br*************@ID-208219.news.uni-berlin.de... * "Newbie!" <s_************@yahoo.co.uk> scripsit: Sorry I know this has probably been asked loads of time, and sorry also
for my stupidity (Im a Newbie!) but ......
I have a Main Form with a button on it. When a user Clicks on the Button
I want it to Open Form2 and Close Form one but for the life of me I carn`t find out where to do it.
<http://www.google.com/groups?selm=u%...TNGP11.phx.gbl
-- Herfried K. Wagner [MVP] <http://www.mvps.org/dotnet>
* "Newbie!" <s_************@yahoo.co.uk> scripsit: I`ve tryed that but it dosn`t work, here goes - I have a 2 Forms (Form1 & Form 2) on Form 1. I have a Button (Button1) in Button1`s code as follows
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim f2 as Form2 f2 = New Form2() f2.Show() Me.Close() End Sub
How ever when i Click on the Button, Form2 loads then closes it`s self stright away, If i take out the Me.Close it stays open but so does Form1
How do I get Form1 to Close When Form2 is loaded?
Do I need any Code else where other than Button1_Click?
No, your code is correct, but your application is loosing its message
pump when closing the form. You will have to use, for example, the code
I referenced in my last post. What doesn't work? Are you sure the
project's startup object is set to 'Sub Main' (in the project
properties)?
--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Hi Newbie,
I have another approach for this than Herfried an Armin and I think it is
not good to interfier with my method. But Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim f2 as Form2 f2 = New Form2() f2.Show() Me.Close() End Sub
That me.close is not good, I use in that case me.hide but I am not sure if
that is also right in the method from Herfried and Armin.
But me.Close closes your program as soon as the button is pushed normaly.
When they are not quick back you can try to add this code in form1 then
also
Private Sub f2_VisibleChanged(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles f2.VisibleChanged
Me.Show()
End Sub
End Class
And dont not know if this is enough in the method you now are using.
But as I said, you can try it.
Cor
OK, i`ve created my TestApp - Form1, & Form2, on Form1 to the top i`ve
added;
Public Class Form1
Inherits System.Windows.Forms.Form
Public Sub Main()
Dim f As Form1
f = New Form1()
Application.Run()
End Sub
And then created a button and added the following code to the button:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim f2 As Form2
f2 = New Form2()
f2.Show()
Me.Close()
End Sub
I`ve change my Project to Run Sub Main at Start-up and also tryed it running
Form1 at Start-Up but i keep getting the following error:
When I try to run my porject I get a Error Saying:
"No accessible 'Main' method with an appropriate signature was found in
'TestAPP'."
Thanks Everyone for your Help So Far.
Ta
Si
"Newbie!" <s_************@yahoo.co.uk> wrote in message
news:oW********************@karoo.co.uk... Hi Group,
Sorry I know this has probably been asked loads of time, and sorry also
for my stupidity (Im a Newbie!) but ......
I have a Main Form with a button on it. When a user Clicks on the Button I want it to Open Form2 and Close Form one but for the life of me I carn`t find out where to do it.
I have the following Code to bring up a Form
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim Form1 As New Form1() Form1.Show() End Sub
I`ve Also Tryed
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim Form1 As New Form1() Form1.Show() Me.Close End Sub
But this opens up Form2 and close`s it again straight Away.
I`ve also tryed Form1.ShowDialog() but that dosn`t seem to help either?
Any bosy got any suggestions on Links?
Ta Si
Hi Newbie,
Did you look to my message or posted this imidiatly nothing is changed in
your code as far as I can see is the "me.close" still there.
If you are only posting without looking to the answers, please tell us, than
we don't have to answer you?
Just a thought,
cor OK, i`ve created my TestApp - Form1, & Form2, on Form1 to the top i`ve added;
Public Class Form1 Inherits System.Windows.Forms.Form
Public Sub Main() Dim f As Form1 f = New Form1() Application.Run() End Sub
And then created a button and added the following code to the button:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim f2 As Form2 f2 = New Form2() f2.Show() Me.Close() End Sub
I`ve change my Project to Run Sub Main at Start-up and also tryed it
running Form1 at Start-Up but i keep getting the following error:
When I try to run my porject I get a Error Saying:
"No accessible 'Main' method with an appropriate signature was found in 'TestAPP'."
Thanks Everyone for your Help So Far.
Ta Si
Sorry Cor i din`t see you post. I`ve Just tryed you suggestion but to no
avail, im so confused.
could you possible e-mail me a testapp with 2 forms on on form1 have a
command button which closes the form1 and opens form2?
Or i could send you my code so far?
My e-mail is si*********@rix.co.uk
Ta
Si
"Cor" <no*@non.com> wrote in message
news:ek**************@TK2MSFTNGP11.phx.gbl... Hi Newbie,
Did you look to my message or posted this imidiatly nothing is changed in your code as far as I can see is the "me.close" still there.
If you are only posting without looking to the answers, please tell us,
than we don't have to answer you?
Just a thought,
cor
OK, i`ve created my TestApp - Form1, & Form2, on Form1 to the top i`ve added;
Public Class Form1 Inherits System.Windows.Forms.Form
Public Sub Main() Dim f As Form1 f = New Form1() Application.Run() End Sub
And then created a button and added the following code to the button:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim f2 As Form2 f2 = New Form2() f2.Show() Me.Close() End Sub
I`ve change my Project to Run Sub Main at Start-up and also tryed it running Form1 at Start-Up but i keep getting the following error:
When I try to run my porject I get a Error Saying:
"No accessible 'Main' method with an appropriate signature was found in 'TestAPP'."
Thanks Everyone for your Help So Far.
Ta Si
Hi Newbie,
I send you 2 beneath pasted even two examples. The last one I never used,
but made once because I saw so many questions about this. (Make those
examples real as two new projects, than you can paste what you like to your
project).
The first example is using a splash screen at start up.
You have to create two forms for it and on both a button.
And than paste this code in both
\\\Main form
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
Dim frm As New Form2
Me.Hide()
frm.ShowDialog()
Me.Show()
frm.dispose
End Sub
///
\\\Sub form 2
Private Sub Form2_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Me.CancelButton = Me.Button1
Me.ControlBox = False
End Sub
///
--------------------------------------------------------
\\\For this one you have to create a project with 3 forms with on the first
one two buttons and a label \\\and on the other two one button.
Private WithEvents frm2 As New Form2
Private WithEvents frm3 As New Form3
Private myActiveForm As Integer
Private Sub Button2_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button2.Click
myActiveForm = 2
frm2.Show()
me.Hide()
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button3.Click
myActiveForm = 3
frm3.Show()
me.Hide()
End Sub
Private Sub frm2_VisibleChanged(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles frm2.VisibleChanged,
frm3.VisibleChanged
Me.Show()
Me.Label1.Text = "Return form = " & myActiveForm.ToString
End Sub
End Class
///
\\\
Public Class Form2
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
Me.Hide()
End Sub
End Class
///
\\\
Public Class Form3
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
Me.Hide()
End Sub
End Class
///
I hope you can find your solution with this?
Cor
Cor,
Many, Many Thanks for you help that worked a treat. Again Many Thanks
And Also Thanks to others that have helped
Ta
Si
"Cor" <no*@non.com> wrote in message
news:uo**************@TK2MSFTNGP12.phx.gbl... Hi Newbie, I send you 2 beneath pasted even two examples. The last one I never used, but made once because I saw so many questions about this. (Make those examples real as two new projects, than you can paste what you like to
your project).
The first example is using a splash screen at start up. You have to create two forms for it and on both a button. And than paste this code in both \\\Main form Private Sub Button1_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles Button1.Click Dim frm As New Form2 Me.Hide() frm.ShowDialog() Me.Show() frm.dispose End Sub /// \\\Sub form 2 Private Sub Form2_Load(ByVal sender As Object, _ ByVal e As System.EventArgs) Handles MyBase.Load Me.CancelButton = Me.Button1 Me.ControlBox = False End Sub /// -------------------------------------------------------- \\\For this one you have to create a project with 3 forms with on the
first one two buttons and a label \\\and on the other two one button. Private WithEvents frm2 As New Form2 Private WithEvents frm3 As New Form3 Private myActiveForm As Integer Private Sub Button2_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles Button2.Click myActiveForm = 2 frm2.Show() me.Hide() End Sub Private Sub Button3_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles Button3.Click myActiveForm = 3 frm3.Show() me.Hide() End Sub Private Sub frm2_VisibleChanged(ByVal sender As Object, _ ByVal e As System.EventArgs) Handles frm2.VisibleChanged, frm3.VisibleChanged Me.Show() Me.Label1.Text = "Return form = " & myActiveForm.ToString End Sub End Class /// \\\ Public Class Form2 Private Sub Button1_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles Button1.Click Me.Hide() End Sub End Class /// \\\ Public Class Form3 Private Sub Button1_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles Button1.Click Me.Hide() End Sub End Class ///
I hope you can find your solution with this?
Cor
"Newbie!" <s_************@yahoo.co.uk> schrieb im Newsbeitrag
news:TK********************@karoo.co.uk... Public Sub Main() Dim f As Form1 f = New Form1() Application.Run() End Sub
When I try to run my porject I get a Error Saying:
"No accessible 'Main' method with an appropriate signature was found in 'TestAPP'."
Add the shared keyword:
Public Shared Sub Main
--
Armin http://www.plig.net/nnq/nquote.html http://www.netmeister.org/news/learn2quote.html This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: fig000 |
last post by:
Hi,
I'm relatively new to Javascript so please bear with me on what
might sound like silly questions.
This is what I want to do:
I'm working in classic asp (I have to for this project). I...
|
by: Mark D. Anderson |
last post by:
About a month ago Richard Cornford did an interesting analysis of a
memory leak
in jscript (internet explorer) when there are "circular" references
between
DOM objects and (real) jscript objects:...
|
by: Tony Johansson |
last post by:
Hello!
I'm reading a book about C++ and there is something that I don't understand
so I ask you.
I have marked the section from the book that is of intertest by tagging it
with BOOK START HERE...
|
by: dog |
last post by:
I've seen plenty of articles on this topic but none of them have been
able to solve my problem.
I am working with an Access 97 database on an NT4.0 machine, which has
many Access reports.
I...
|
by: Dominic |
last post by:
Hi guys,
I'm not sure if this question belongs to FAQ, but I couldn't find a
concrete answer.
I created a Datagrid control using ItemTemplate, but it's NOT a
in-place editing datagrid. One of...
|
by: Kirk McDonald |
last post by:
Say I have a database containing chunks of Python code. I already have a
way to easily load, edit, and save them. What is slightly baffling to me
is how I can effectively pass this code some...
|
by: Kaur |
last post by:
Hi,
I would appriceate any help to correct the code error that I am getting
for the onclick event of a cmd button. I have two forms. Main Form
"frmQuestion" and form 2 "SfrmQuestion"....
|
by: P. Adhia |
last post by:
Sorry for quoting an old post and probably I am reading out of context
so my concern is unfounded. But I would appreciate if I can get someone
or Serge to confirm. Also unlike the question asked in...
|
by: quickcur |
last post by:
Hi, can anyone point me a library that can read image to memory from a
URL? It is very easy in Java, but it is hard to find an complete
solution in c/c++.
Thanks,
|
by: james |
last post by:
Hi all,
I did some quick searching but I haven't found anything like I want.
It probably has to do with the terms I am searching for so if I
describe what I want then I hope someone can point me...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
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,...
|
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...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |