Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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

-----------------

It�s always funny until someone gets hurt� Then it become hilarious!

Posted (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 by ukjock

-----------------

It�s always funny until someone gets hurt� Then it become hilarious!

Posted

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

-----------------

It�s always funny until someone gets hurt� Then it become hilarious!

  • Administrators
Posted

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

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

Posted (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 by ukjock

-----------------

It�s always funny until someone gets hurt� Then it become hilarious!

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...