Sunday, May 04, 2008

Okay...so I am working on my project and things are going well with one exception...

I am using multiple forms and I can't figure out how to use an object that lives on one form on another form...

For example...I created a radFemale object on Form 1.  Now on Form3 I want to say if radFemale.checked = True then do the following equation.  However when I try to use it on the code for Form3 obviously it does not recognize it.  Then I am also trying to use the result for (ie:) decWeight which is captured on Form2 in this equation on to place results on Form3...what am I doing wrong/missing?  I am trying to follow the slides from the last week of class about using multiple forms, but I just am not following the whole parent/child form and how to use a result from one form on another!  Anyone know of any good websites that talk about using multiple forms?  I have been looking the last couple of days and have not come up with any.

 

 

5/4/2008 7:44:15 PM (Central Standard Time, UTC-06:00)  #    Comments [2]Trackback
5/5/2008 8:50:42 AM (Central Standard Time, UTC-06:00)
Mara,
In the code for Form3 create a variable called:

Private frm1 as New Form1
(replace Form1 with whatever the actual name of form1 is)

Then you can call the radFemale from Form1 on Form3:

frm1.radFemale.Checked = True

I used this code with a variable but I'm thinking it should work. I'm also at work right now so I can't actually look at my code so I'm just going from memory. Hopefully this works for you. I'll check my coding when I get home if there is something I missed.
5/5/2008 11:08:00 AM (Central Standard Time, UTC-06:00)
As shown in class, use properties of the Form to pass information between forms.

What is the information that the next form needs to know?
I assume that in this case your Form3 needs to know which selection was made regarding the kind of calculation that you want to perform.

So you want to determine the kind of calculation in Form1 and store it in a variable (i.e., thisCalculationType As String ... to keep it simple).
Then your Form3 has a public property (i.e., CalculationType ... also a string). You then create the new Form3 (i.e., Dim frm3 as new Form3 ) and assign the calculation type determined in the first form to the property for calculation type in Form3 ( frm3.CalculationType = thisCalculationType).

MH
MH
Name
E-mail
Home page

Comment (HTML not allowed)  

Enter the code shown (prevents robots):