form instances!!

T

Tonya

Hi,

I am having trouble when trying to open up form instances.
When i currently click on a button (button1) in form1 i
open up form2,
However when i go back to my homepage (form1) and click
button1 again i get another instance of form2 opening
instead of the same form!!

I have tried the following code to make the forms globbaly
available but for some reason i keep getting an error
message. here is my code (i created a new class at the top
of the code editor)....

Public Class myForms
Private Shared m_form2 As form2
Public Shared Property form2() As form2
Get
Return m_form2
End Get
Set(ByVal Value As form2)
m_form2 = Value
End Set
End Property
End Class

i then added the following code to the button1

Dim myform2 As New form2()
myform2.Show()
myForms.form2= myform2

is this the right way to go about it or is there an easier
way?? im new to vb.net and am very confused!!

i got this code example from...
http://msdn.microsoft.com/library/default.asp?
url=/library/en-
us/dv_vstechart/html/vbtchworkingwithmultipleformsinvisualb
asicnetupgradingtonet.asp

here is the error message i keep recieveing. The code
seems to stop in the windows genereated code for my
form1...

An unhandled exception of
type 'System.Resources.MissingManifestResourceException'
occurred in mscorlib.dll

Additional information: Could not find any resources
appropriate for the specified culture (or the neutral
culture) in the given assembly. Make
sure "frmHome.resources" was correctly embedded or linked
into assembly "Caravan".
baseName: frmHome locationInfo: Caravan.frmHome resource
file name: frmHome.resources assembly: Caravan,
Version=1.0.1464.24080, Culture=neutral,
PublicKeyToken=null



i appreciate any help anyone can offer :blush:)
thx
 
C

Cor

Hi Tonya,

I once made this form with a different approach

Look if it works for you?

Cor

Hi x

\\\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
///
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top