ukjock Posted December 10, 2003 Posted December 10, 2003 I am having difficulties getting my head around this .net software. I was learning vb6 and then the company decides to buy me vb.net to which i must open and have a play about with. But I am having issues with copying information from a textbox in one form to a label in another. Normally I would code in: Dim m as main m.label6.text = textbox1.text and then it returns -------------------- An unhandled exception of type 'System.NullReferenceException' occurred Additional information: Object reference not set to an instance of an object. -------------------- I also tried doing: If RadioButton2.Checked = True Then m.PictureBox10.Image = PictureBox2.Image but it still returns the same error. Any idea why? Any help appreciated on this one, as I have been trying to figure this one out for myself since Saturday Thanks Chris Quote ----------------- It�s always funny until someone gets hurt� Then it become hilarious!
Administrators PlausiblyDamp Posted December 10, 2003 Administrators Posted December 10, 2003 Dim m as new main() m.label6.text = textbox1.text In .Net forms are objects like everything else. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
ukjock Posted December 10, 2003 Author Posted December 10, 2003 (edited) Does the Dim m As New main() apply if the form is currently active when trying to copy the data across? I have tried searching through the objects but I can not see anything along the lines of Dim m as Existing main() or am I being thick here? Edited December 10, 2003 by ukjock Quote ----------------- It�s always funny until someone gets hurt� Then it become hilarious!
ukjock Posted December 10, 2003 Author Posted December 10, 2003 Still struggling with my project. Below is an image of what it looks like. http://www.ch010a0005.pwp.blueyonder.co.uk/image4project.jpg The lined off area is a form called addcaller.vb behind it is a form called main. When I add text to the textbox's in the addcaller form and click ok the following should happen. The contents of the textbox's, from the addcallers form, should copy across to replace the text on 1 on the main form. I used the following code: Dim m As New main Dim N As String Dim L As String Dim T As String N = TextBox1.Text L = TextBox2.Text T = TextBox3.Text If Label8.Text = 1 Then m.Label6.Text = N m.Label7.Text = L m.Label5.Text = T End If Me.Close() End Sub It doesn't work, it just closes the addcaller form. I am now pulling my hair out, any help appreciated. Chris Quote ----------------- It�s always funny until someone gets hurt� Then it become hilarious!
Administrators PlausiblyDamp Posted December 10, 2003 Administrators Posted December 10, 2003 Is the form main the startup form for the application? If so when you launch the other forms you will need to pass a reference to main. http://www.xtremedotnettalk.com/showthread.php?s=&threadid=75911 http://www.xtremedotnettalk.com/showthread.php?s=&threadid=73538 Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
ukjock Posted December 11, 2003 Author Posted December 11, 2003 (edited) Thanks for everyone's help. I got there eventually, I can see re-learning visual basic is going to be fun :D Chris Edited December 11, 2003 by ukjock Quote ----------------- It�s always funny until someone gets hurt� Then it become hilarious!
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.