472,378 Members | 1,503 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,378 software developers and data experts.

Simple - Show Form

dp
I am new to VB.NET and I have a simple question. How do I show a form
from a command button click event? The code I have below is not
working. I am trying to show the form frmAgent. What am I missing?

Private Sub cmdNewAgent_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles cmdNewAgent.Click
Dim frm1 As New frmAgent()
frm1.Show()
Me.Hide()
End Sub
Jul 19 '05 #1
3 6597
What's happening? There's nothing wrong with that code as it appears.

If you put a breakpoint on the click event and hit the button, are you
definitely hitting it in the code window?
"dp" <da**@solidservices.net> wrote in message
news:d1**************************@posting.google.c om...
I am new to VB.NET and I have a simple question. How do I show a form
from a command button click event? The code I have below is not
working. I am trying to show the form frmAgent. What am I missing?

Private Sub cmdNewAgent_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles cmdNewAgent.Click
Dim frm1 As New frmAgent()
frm1.Show()
Me.Hide()
End Sub

Jul 19 '05 #2
Rob:

Are you sure about that? Every time you fire a new form you need to send
Application.Run(frm1);?

Why would that cause Form2 not to show?
"Rob Windsor" <rw******@NO.MORE.SPAM.bigfoot.com> wrote in message
news:uX*************@TK2MSFTNGP11.phx.gbl...

You need to change "frm1.Show()" to "Application.Run(frm1)". If you just use the show method the form will close when the variable frm1 goes out of
scope.

--
Rob Windsor
G6 Consulting
Toronto, Canada

"dp" <da**@solidservices.net> wrote in message
news:d1**************************@posting.google.c om...
I am new to VB.NET and I have a simple question. How do I show a form
from a command button click event? The code I have below is not
working. I am trying to show the form frmAgent. What am I missing?

Private Sub cmdNewAgent_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles cmdNewAgent.Click
Dim frm1 As New frmAgent()
frm1.Show()
Me.Hide()
End Sub


Jul 19 '05 #3
If you want to show a non-modal form you need to use Application.Run(<form
variable>) to set up a message loop on the form's thread. If you don't do
this (i.e. you use the Show method) the form closes when the variable that
refrences it goes out of scope. In the previous message that was when the
event handling subroutine ended. Note that this is not required for modal
forms, the ShowDialog method does this for you.

Rob

"William Ryan" <do********@comcast.nospam.net> wrote in message
news:OJ*************@TK2MSFTNGP10.phx.gbl...
Rob:

Are you sure about that? Every time you fire a new form you need to send
Application.Run(frm1);?

Why would that cause Form2 not to show?
"Rob Windsor" <rw******@NO.MORE.SPAM.bigfoot.com> wrote in message
news:uX*************@TK2MSFTNGP11.phx.gbl...

You need to change "frm1.Show()" to "Application.Run(frm1)". If you just

use
the show method the form will close when the variable frm1 goes out of
scope.

--
Rob Windsor
G6 Consulting
Toronto, Canada

"dp" <da**@solidservices.net> wrote in message
news:d1**************************@posting.google.c om...
I am new to VB.NET and I have a simple question. How do I show a form
from a command button click event? The code I have below is not
working. I am trying to show the form frmAgent. What am I missing?

Private Sub cmdNewAgent_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles cmdNewAgent.Click
Dim frm1 As New frmAgent()
frm1.Show()
Me.Hide()
End Sub



Jul 19 '05 #4

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

Similar topics

0
by: steve w | last post by:
Hi there I'm trying to do something that in ASP I could do easily. I want a form which will... 1. Bind a record from a database to the text boxes etc. if the user has come from a summary...
14
by: alwayshouston | last post by:
Hi All! I am working on this very small database and I am confused in the designing a simple form. I only have three tables in the database. First Table: tblExpense Columns: ExpenseID ;...
0
by: Tal Sharfi | last post by:
Hi everyone I recently had the need for StringGrid object same as the one that Delphi has. An object that helps show lists of other objects in a simple grid. I searched the news groups and...
3
by: VMI | last post by:
How difficult is it to hide my program in the system tray? It's not something that's required, but it'd look to add it since the program will be writing an ascii file every minute. And it wouldn't...
0
by: Harley | last post by:
Hello, I am just learning the tcp/ip functions etc under vb.net so please look over me if this is obviouse. I have been all over looking into any functions that I didn't totaly understand and...
3
by: dp | last post by:
I am new to VB.NET and I have a simple question. How do I show a form from a command button click event? The code I have below is not working. I am trying to show the form frmAgent. What am I...
4
by: Duncan | last post by:
Hi I'm learning c# 2.0 as I feel I need to be able to switch between vb & c#, I'm just starting with a few simple examples and I've come across a problem. I've got two forms ones an MDI parent &...
1
by: www.web20developers.com | last post by:
http://www.web20developers.com http://www.web20developers.com/index.php?option=com_content&task=view... Ajallerix : AJAX, simple, fast Web image gallery demo ; at Novell AJAX -...
3
by: deejayquai | last post by:
Hello Simple one this I guess, but I'm quite stuck at the moment. I would like to update the records displayed in my listbox (lstStudents) using criteria selected from my combo (cboForm) in a...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge required to effectively administer and manage Oracle...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was proposed, which integrated multiple engines and...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the synthesis of my design into a bitstream, not the C++...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand. Background colors can be used to highlight important...
0
BLUEPANDA
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS starter kit that's not only easy to use but also...
0
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python has gained popularity among beginners and experts...
2
by: Ricardo de Mila | last post by:
Dear people, good afternoon... I have a form in msAccess with lots of controls and a specific routine must be triggered if the mouse_down event happens in any control. Than I need to discover what...
1
by: ezappsrUS | last post by:
Hi, I wonder if someone knows where I am going wrong below. I have a continuous form and two labels where only one would be visible depending on the checkbox being checked or not. Below is the...
0
by: jack2019x | last post by:
hello, Is there code or static lib for hook swapchain present? I wanna hook dxgi swapchain present for dx11 and dx9.

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.