By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,515 Members | 1,061 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,515 IT Pros & Developers. It's quick & easy.

Passing Values between Forms

P: n/a

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
Nov 20 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
"=?Utf-8?B?V2lsbA==?=" <Wi**@discussions.microsoft.com> wrote in
news:22**********************************@microsof t.com:

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.

--
Lucas Tam (RE********@rogers.com)
Please delete "REMOVE" from the e-mail address when replying.
http://members.ebay.com/aboutme/coolspot18/
Nov 20 '05 #2

P: n/a
"=?Utf-8?B?V2lsbA==?=" <Wi**@discussions.microsoft.com> wrote in
news:0D**********************************@microsof t.com:
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.

--
Lucas Tam (RE********@rogers.com)
Please delete "REMOVE" from the e-mail address when replying.
http://members.ebay.com/aboutme/coolspot18/
Nov 20 '05 #3

P: n/a
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" <Wi**@discussions.microsoft.com> wrote in message
news:22**********************************@microsof t.com...

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

Nov 20 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.