thankins Posted October 29, 2003 Posted October 29, 2003 Here is my probelm, I have one project and multiple forms. The main form called frmMain has blank labels on them to display totals, my second form called frmWheels, has radio buttons that contain text that shows the price. And when the user selects a radio button and then click a ADD button the the form to copy the price to the first form blank label. My problem is that I dont know how to get the prices from the second form to the first form Quote
jamesanthony Posted October 29, 2003 Posted October 29, 2003 try using the format FORM1.TXTBOX.VALUE=FORM2.TXTBOX.VALUE a GLOBAL variable would usually suffice but bill does'nt like these any more. Don't know why Quote
thankins Posted October 29, 2003 Author Posted October 29, 2003 so you mean something like this frmMain.lblTotalDisplay.Text = frmWheel.wheelPrice , where WheelPrice is a variable storing the value from the selected radio button on the second form? Quote
sde Posted October 29, 2003 Posted October 29, 2003 i think you need to pass a reference from the first form to the second .. something like this: // first form FormWheels frmWheels = new FormWheels(this); frmWheels.Show(); declare FormMain and add it as an argument to the constructor of the second form. then you can target anything on frmMain from frmWheels. Make sure anything you want to target is "public" though. otherwise it won't work. Quote codenewbie
*Experts* mutant Posted October 29, 2003 *Experts* Posted October 29, 2003 You would have to pass the instance of the first form to the second one to access it from the second form. Here is how you could do it: In the second form find the constructor and edit it so it looks like this: 'a variable that you will use in your second from to reference the nistance of the first one Dim firstform As Form1 Public Sub New(byval form1var As Form1) 'accept an instance of the form firstform = form1var 'assign the passed in instance to the local variable MyBase.New() InitializeComponent() End Sub Then you can access the passed in instance using the firstform variable. Now, when declaring a new instance Form2 declare it like this: Dim secondform As New Form2(Me) Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.