 |
VB.NET 2002/2003 Basics For coders who are new to Visual Basic, working in .NET versions 2002 or 2003 (1.0 and 1.1). |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the VB.NET 2002/2003 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|

May 25th, 2004, 05:14 PM
|
Registered User
|
|
Join Date: May 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Incredibly Basic Question, pop up form
I have spent awhile making my first fully functional Visual Basic program. I have been kind of learning it as I go along. I have almost finished my project but I would like to have a pop up form appear when a basic if else statement is true.
This simple thing seems to be the hardest to find the answer to. I have the pop up form all made and right now it's just another form in my project...
Thanks for all the help, and feel free to laugh.:D
|

May 26th, 2004, 09:12 AM
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 1,101
Thanks: 0
Thanked 2 Times in 2 Posts
|
|
Webforms or Winforms?
Hal Levy
Web Developer, PDI Inc.
NOT a Wiley/Wrox Employee
|

May 26th, 2004, 09:51 AM
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 540
Thanks: 0
Thanked 4 Times in 4 Posts
|
|
Dim frm As New Name_of_Form
frm.ShowDialog()
or
frm.Show()
J
|

June 11th, 2004, 07:26 PM
|
Registered User
|
|
Join Date: Jun 2004
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
I have this same question. The last suggestion on this forum doesn't seem to work. I will state the question again.
I have vb.net program with two forms, Form1 and Form2. When I start the program, only Form 1 is visable. If I add a button to Form1, what do I enter to make Form2 visible, and then how do I hide Form 2. As an example, in VB 6, I would enter Form2.show to show the form, nothing more. I would enter Form2.hide to hide the form.
What do I do in VB.net???
Thanks.
Hamil
|

June 12th, 2004, 03:00 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Hi Hamil
(Would you mind posting to this forum instead of e-mailing me your questions directly?? Thanks)
I think the last solution should work:
Dim frm As New Name_of_Form
frm.ShowDialog()
This creates a new instance of your form (the form's ID is Name_of_Form) and then this instance is displayed using ShowDialog().
What's the problem you're having with this solution?
Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
|

June 12th, 2004, 08:23 AM
|
Registered User
|
|
Join Date: Jun 2004
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
First, excuse me for the email. I did not know how often you or others read this forum so I thought a direct email might get a faster response.
Dim frm As New Name_of_Form
frm.ShowDialog()
When doing the above, it seems to me that a new form is being created by the statement "Dim frm As New Name_of_Form" at run time and then displayed. I am trying to turn on a form that has been created at design time.
What I am trying to do, in most simple terms is. Assume I create a new project with two forms, Form1 and Form2. I place a button on Form1. When I run the project, only Form1 is initially displayed. So I want to add code to the button event so that when I click it, Form2 displays. I also want a button on Form2 such that when clicked would cause Form2 to hide.
Thanks.
Hamil
|

June 12th, 2004, 08:41 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
That is correct, but that is also exactly how it is supposed to work. At design time, you describe how the form looks. That is, you actually create a class / definition of the form. When you want to display it at run-time, you'll need to create an instance of that class which you can then show.
So, the code shown earlier does what it is supposed to do: create and display a new Form2. See the design time form as a template, and the run-time form as a real form based on that template. The template by itself can do nothing, so you need to create a form out of it first.
Cheers,
Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
|

June 12th, 2004, 08:44 AM
|
Registered User
|
|
Join Date: Jun 2004
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Imar, or other responder. I just tried what you suggested and it doesn't work. Perhaps there is some other basic assumption I am missing.
Here is mhy bad code.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim frm As New Name_of_Form
frm.ShowDialog()
'I want this button to show Form2
End Sub
End Class
Thanks
h
|

June 12th, 2004, 08:50 AM
|
Registered User
|
|
Join Date: Jun 2004
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Imar..
Thanks..
I finally got it!
I have to get over the VB 6 way of thinking.
Hamil.
|

June 12th, 2004, 08:52 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
And what do you think Name_of_Form is supposed to be?? It's not a special keyword, it should contain the name of your form ;)
Dim frm As New Form2
frm.ShowDialog()
Cheers,
Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
|
|
 |