Getting Information From Another Form

Please support our VB.NET advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Jun 2009
Posts: 4
Reputation: Darkicon is an unknown quantity at this point 
Solved Threads: 0
Darkicon Darkicon is offline Offline
Newbie Poster

Getting Information From Another Form

 
0
  #1
Jul 7th, 2009
I'm stumped right now, I cannot figure out how to code something to get information from another form.

This is what I'm trying to do:

  1. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  2. If TextBox1.Text = "01" Then 'TextBox1 is in form 2.
  3. PictureBox1.Image = System.Drawing.Bitmap.FromFile(My.Application.Info.DirectoryPath & "\Image00001.png") 'PictureBox1 is in form 1.
  4. ElseIf TextBox1.Text = "02" Then 'TextBox1 is in form 2.
  5. PictureBox1.Image = System.Drawing.Bitmap.FromFile(My.Application.Info.DirectoryPath & "\Image00002.png") 'PictureBox1 is in form 1.
  6. End If
  7. End Sub

When I use that code, it tells me that PictureBox1 is not declared, it's because it's not in the same form as TextBox1 and the button.

I know it's probably extremely simple, but I just can't figure it out.
Reply With Quote Quick reply to this message  
Join Date: Jul 2009
Posts: 4
Reputation: winkler is an unknown quantity at this point 
Solved Threads: 1
winkler's Avatar
winkler winkler is offline Offline
Newbie Poster

Re: Getting Information From Another Form

 
0
  #2
Jul 7th, 2009
Hi
Was one of the forms called (or created) in the other?
for example
  1. dim f as new form1
  2. f.show()
If yes, then the "parent" form can access the other forms controls by prefacing it with the form name for example
  1. f.PictureBox1
It should appear in intellisense.
Otherwise you could create a public variable on the form and then assign the value to it through that.
Hope that helps.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC