472,791 Members | 1,086 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,791 software developers and data experts.

creating a vb.net project with multiple forms

Don
hi

in the past (vb 5.0) is used to create applications with multiple forms. i would hide and/or show the appropriate form depending on user input. now i'm using vb.net (still getting used to it) and can not figure out how to hide and show forms. my project presently has a few forms but i can only the startup form is visible. i can't hide the startup form or show the other forms. i would like to hide a form when a button is pressed and then show another

thanks in advance
Nov 22 '05 #1
5 7053

"Don" <am****@ix.netcom.com> wrote in message
news:74**********************************@microsof t.com...
hi:

in the past (vb 5.0) is used to create applications with multiple forms. i would hide and/or show the appropriate form depending on user input. now
i'm using vb.net (still getting used to it) and can not figure out how to
hide and show forms. my project presently has a few forms but i can only
the startup form is visible. i can't hide the startup form or show the
other forms. i would like to hide a form when a button is pressed and then
show another.
thanks in advance


To get used to the procedure, do the following:
Create a simple VB Windows project, then add a second form to it.
Place a label on each form so you can identify which form is displayed.
Place a button on each form.

Place the following code in the Click event procedure of the button on Form1
' create instance of Form2
Dim my2 As New Form2
'Hide current form

Me.Hide()

'Display new instance

my2.ShowDialog()

Place the following code in the Click event procedure of the button on Form2
Dim my1 As New Form1

Me.Hide()

my1.ShowDialog()

Hope this helps.
--
Peter [MVP Visual Developer]
Jack of all trades, master of none.
Nov 22 '05 #2

"Don" <am****@ix.netcom.com> wrote in message
news:74**********************************@microsof t.com...
hi:

in the past (vb 5.0) is used to create applications with multiple forms. i would hide and/or show the appropriate form depending on user input. now
i'm using vb.net (still getting used to it) and can not figure out how to
hide and show forms. my project presently has a few forms but i can only
the startup form is visible. i can't hide the startup form or show the
other forms. i would like to hide a form when a button is pressed and then
show another.
thanks in advance


To get used to the procedure, do the following:
Create a simple VB Windows project, then add a second form to it.
Place a label on each form so you can identify which form is displayed.
Place a button on each form.

Place the following code in the Click event procedure of the button on Form1
' create instance of Form2
Dim my2 As New Form2
'Hide current form

Me.Hide()

'Display new instance

my2.ShowDialog()

Place the following code in the Click event procedure of the button on Form2
Dim my1 As New Form1

Me.Hide()

my1.ShowDialog()

Hope this helps.
--
Peter [MVP Visual Developer]
Jack of all trades, master of none.
Nov 22 '05 #3
Hi Don,

There are in VB.net a lot of methods to do that.

Peter did show you a method with a dialogform, it is not real hiding because
the dialogform is everytime new instanced, so the information on it will be
lost. Here a sample with 3 forms which are all the time active, although
form1 is the major form. As a third major form there is the MDI form, where
in a formcontainer can be a lot of child forms.

Most classic VB programmers or the ones comming from C are using a
application.start module, however that is not really necassery in VB.net
because that is build in the form class itself.

I hope this helps?

Cor

\\\form1
Private WithEvents frm3 As New Form3
Private WithEvents frm2 As New Form2
Private Sub frm2_VisibleChanged(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles frm2.VisibleChanged
If frm2.inputfield <> "" Then
Me.Show()
Me.Label1.Text = frm2.inputfield
frm2.Dispose()
End If
End Sub
Private Sub frm3_VisibleChanged(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles frm3.VisibleChanged
If frm3.inputfield <> "" Then
Me.Show()
Me.Label1.Text = frm3.inputfield
frm3.Dispose()
End If
End Sub

Private Sub Form1_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
frm3.Show()
frm3.TopLevel = True
frm2.Show()
frm2.TopLevel = True
End Sub
///
\\\form2 and 3 the same
Public inputfield As String
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click

inputfield = "sometext"
Me.Hide()
End Sub
///

Nov 22 '05 #4
Hi Don,

There are in VB.net a lot of methods to do that.

Peter did show you a method with a dialogform, it is not real hiding because
the dialogform is everytime new instanced, so the information on it will be
lost. Here a sample with 3 forms which are all the time active, although
form1 is the major form. As a third major form there is the MDI form, where
in a formcontainer can be a lot of child forms.

Most classic VB programmers or the ones comming from C are using a
application.start module, however that is not really necassery in VB.net
because that is build in the form class itself.

I hope this helps?

Cor

\\\form1
Private WithEvents frm3 As New Form3
Private WithEvents frm2 As New Form2
Private Sub frm2_VisibleChanged(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles frm2.VisibleChanged
If frm2.inputfield <> "" Then
Me.Show()
Me.Label1.Text = frm2.inputfield
frm2.Dispose()
End If
End Sub
Private Sub frm3_VisibleChanged(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles frm3.VisibleChanged
If frm3.inputfield <> "" Then
Me.Show()
Me.Label1.Text = frm3.inputfield
frm3.Dispose()
End If
End Sub

Private Sub Form1_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
frm3.Show()
frm3.TopLevel = True
frm2.Show()
frm2.TopLevel = True
End Sub
///
\\\form2 and 3 the same
Public inputfield As String
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click

inputfield = "sometext"
Me.Hide()
End Sub
///

Nov 22 '05 #5
well kid the method to implement multiple form is as follows:
add a class to your project named FormLibrary

code as follows

Public Class FormLibrary
Public Shared Form1 As Form
Public Shared Form2 As Form
End Class
then in the form_load event of the different forms add:

FormLibrary.Form1 = Me

for form2 load event

FormLibrary.Form2 = Me

then u may freely access the form properties from any other form as your old habbit using such syntax

FormLibrary.Form1.Hide()
or
FormLibrary.Form2.Show()

You may also do that with a friend class rather than the public class

further dot Net has brought the feature of creating instances of other forms within other forms

code in form1

Dim fm2 as New Form2
fm2.Show()

BUT dont Confuse it with the above methods coz it creates new instance of the form

to know further about the fundas involved email me

check my sites (my childhood creation)

http://3kd.resourcez.com (developed in 2002)
http://humanpsychology.resourcez.com (developed in 2001)
---
Posted using Wimdows.net NntpNews Component -

Post Made from http://www.DotNetJunkies.com/newsgroups Our newsgroup engine supports Post Alerts, Ratings, and Searching.
Nov 22 '05 #6

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

Similar topics

1
by: Don | last post by:
hi in the past (vb 5.0) is used to create applications with multiple forms. i would hide and/or show the appropriate form depending on user input. now i'm using vb.net (still getting used to it)...
1
by: john sutor | last post by:
I have a main form in a project that launches other forms. How do I ensure that the same form does not get launched twice without killing the orignal form. I other words I need a method to manage...
7
by: Jeff | last post by:
I plan to write a Windows Forms MDI application for a medical office. Users must be able to select a patient and view related information on multiple forms; with1-4 forms opened at the same time...
5
by: c676228 | last post by:
Hi everyone, my colleagues are thinking about have three insurance plans on one asp page: I simplify the plan as follow: text box:number of people plan1 plan2 plan3
5
by: dancole42 | last post by:
I want to create a button that will print multiple forms. Each form is a list of various orders, and there are three separate forms: -Standard Orders -Rush Orders -VIP Rush Orders Each is...
12
by: rents | last post by:
hello all, I have a project due by the end of the this week. with this particular project, we are to use "multiple forms." I'm a little shaky on this concept. So here is the description of the...
3
by: tigger | last post by:
I have a problem with my project. I have multiple forms. In the main form, I'll have to click on a button where by another form will appear. However, I cannot return to my main form without having to...
0
by: Demonweare | last post by:
Beginner Alert! How do I access public members from different classes at runtime? For example, I have a C#.NET project that uses multiple forms and I need to be able to get values from controls...
2
by: =?Utf-8?B?VGFtbXkgTmVqYWRpYW4=?= | last post by:
Hi, I am going to write a large application using Visual Studio C#. I am going to use only one Form as main menu and go to other pages by cliking on next button in each page. I dont want to create...
2
by: Shirisha B | last post by:
How to declare connection string globally while doing a project in multiple forms?
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Sept 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: lllomh | last post by:
How does React native implement an English player?
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

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.