Passing Values between Forms

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

hi

i have 2 forms (frm1,frm2) .. i launch frm2 by clicking a button on frm1. on frm2 there is another button. when i click on the button on frm2, i want the background color of frm1 to change yet i want to leave frm2 visible and not close it ..

NEED CODE PLEASE
THANX IN ADVANCE
 
hi

i have 2 forms (frm1,frm2) .. i launch frm2 by clicking a button on
frm1. on frm2 there is another button. when i click on the button
on frm2, i want the background color of frm1 to change yet i want
to leave frm2 visible and not close it ..


You'll need to pass a reference to frm1 in the constructor of frm2. Then
you can call a frm1 public method to change the color.
 
makes sense .. but can you please show me some example, code ?

Class Form2
Private ref_frmForm1 as TypeofForm1

Public Sub New(ByRef Form1 as TypeOfForm1)
ref_frmForm1 = Form1
End Sub

Private Sub ChangeColorOnForm1()
ref_formForm1.PublicChangeColorFunction
End Sub
End Class


From Form1

Private Sub LaunchForm2()
Dim frmForm2 as Form2 = new Form2(Me)

frmForm2.show()
End Sub


Not sure if this is the best way, but it works.
 
The best way that I found of doing this was to have a startup module, and
place this code within it:-

Module Startup
Public myMainForm As frmApplication
Sub Main()
myMainForm = NewfrmApplication
Windows.Forms.Application.Run(myMainForm)
End Sub
End Module


Will said:
hi

i have 2 forms (frm1,frm2) .. i launch frm2 by clicking a button on
frm1. on frm2 there is another button. when i click on the button on frm2, i
want the background color of frm1 to change yet i want to leave frm2 visible
and not close it ..
 
Back
Top