PDA

Click to See Complete Forum and Search --> : Changes from VB6 to VB.NET


Albino
Sep 23rd, 2002, 05:44 AM
Hi there! I've been programming for a while now, but VB.NET came and destroyed my experince. This is my problem:

I've got two forms: Form1 and Form2. Form1 is opened first and then i open Form2. I want to send Form2.Text to Form1.Text. How do i do this? In VB6 i just wrote:

Form1.Text = Form2.Text

(I wan't to do this operation while standing with focus on Form2. So the operation will be done when i push a button on Form2.)

But it's different in VB.NET. Right? :confused: I have acomplished to take data from a other form, but i don't know how to send data to another form! Please help me!!! :D

PT Exorcist
Sep 23rd, 2002, 06:07 AM
dim mform1 as new form1
dim mform2 as new form2

mform1.text="lol"
mform2.text=mform1.text


learn to use msdn or search in the foruns cuz ppl start getting sick of answerind always the same *EASY* questions that can be found everywhere...

btw...this is the way OOP works..if u dont know plz buy a book cuz its all very diferent and is better u learn the theory cuz using old-style vb6 sucks in vb.net

Albino
Sep 23rd, 2002, 08:45 AM
It doesn't work. I still don't know how to set the Form1.Text from within the code of Form2.

Have you tried it your self? Can you send me a sample that does this *EASY* operation? :mad:

Hu Flung Dung
Sep 23rd, 2002, 11:41 AM
Originally posted by Albino
It doesn't work. I still don't know how to set the Form1.Text from within the code of Form2.

Have you tried it your self? Can you send me a sample that does this *EASY* operation? :mad:

You may know VB6, but VB.NET is a completely different language!

Go buy a book on it!

Oh, and PT's code should work, how did you write it?

Andy
Dec 1st, 2003, 02:40 AM
Originally posted by PT Exorcist

dim mform1 as new form1
dim mform2 as new form2

mform1.text="lol"
mform2.text=mform1.text


learn to use msdn or search in the foruns cuz ppl start getting sick of answerind always the same *EASY* questions that can be found everywhere...

btw...this is the way OOP works..if u dont know plz buy a book cuz its all very diferent and is better u learn the theory cuz using old-style vb6 sucks in vb.net

did you ever stop to think this member DID search? I searched for the same problem but his is the only one I found.

PT Exorcist
Dec 1st, 2003, 07:15 AM
did you ever stop to think this member DID search? Are you him with a different nickname? If yes, if searched did a bad search, if not i think you should be quiet as you dont know if he actually did it or not.

Also it's not you who at that time(a year ago) had to answer everyday to the same basic posts that sometimes in the main vb.net forum page could be found several times and people just keeped asking instead of going to look at some posts bellow.

DevGrp
Dec 1st, 2003, 09:29 AM
Originally posted by PT Exorcist

dim mform1 as new form1
dim mform2 as new form2

mform1.text="lol"
mform2.text=mform1.text


learn to use msdn or search in the foruns cuz ppl start getting sick of answerind always the same *EASY* questions that can be found everywhere...

btw...this is the way OOP works..if u dont know plz buy a book cuz its all very diferent and is better u learn the theory cuz using old-style vb6 sucks in vb.net
This is not gonna work because those text boxes are declared private. There are 2 solutions.
1. The form you wanna get the text from, you can change the textbox from private to public. I would'nt suggest this since this is not following OOP rules.
2. On the form you want to get the text from, create a property that exposes the text box.

Public Property MyText() as String
Get
Return TextBox1.Text
End Get
End Property

Albino
Dec 1st, 2003, 10:30 AM
Think I've solved the problem by now:

In Form1 I've written this:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim frm As New Form2(Me)
frm.Show()
End Sub


and I've declared a private variable of the type Form1 like this:
Private prevForm As Form1

Then I changed a bit on Form2's new-procedure:
Public Sub New(ByVal parentForm As Form1)
MyBase.New()
Me.prevForm = parentForm
InitializeComponent()
End Sub

And then at last I've changed Form2' Button1 to this:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
prevForm.Text = "Haba haba!"
End Sub


This works.... I think...

Andy
Dec 5th, 2003, 08:14 PM
Originally posted by PT Exorcist
Are you him with a different nickname? If yes, if searched did a bad search, if not i think you should be quiet as you dont know if he actually did it or not.

Also it's not you who at that time(a year ago) had to answer everyday to the same basic posts that sometimes in the main vb.net forum page could be found several times and people just keeped asking instead of going to look at some posts bellow.

no, I'm not the gentleman under a disguise. I'm too old to play games like that.

No, I don't know whether or not he searched. You and I are alike in at least one way...we both are tired of unnecessary posts.

Albino
Dec 5th, 2003, 08:47 PM
I did search for help first, but didn't find anything. So this was my last option, but since you couldn't give me a correct answer I had to find the soultion my self. You know... This is a forum, and if you get angry because someone asks a question, you got yourself a serious problem! Doesn't matter if someone has answered the easy question befor! Give the questioner a link to where the answer can be found instead of writing a lot about all the *stupid* people that have to use the forum! The forum is here because you can help people that aren't that good in vb.

Hole-In-One
Dec 5th, 2003, 09:41 PM
I agree with Albino, if your not here to help, then why are you here?

I you don't like or agree with a post, don't answer it, just ignore it.

But I must add that there are many helpful people here in the forums, that would help you out in anyway possible.:D

brad jones
Dec 5th, 2003, 10:34 PM
Originally posted by Hole-In-One
I you don't like or agree with a post, don't answer it, just ignore it.



I agree with this statement and ask that everyone "play nicely". Let's keep any additional post in this thread focused on communicating or passing information between forms. The other comments can be placed in feedback or done in PMs.

Thanks,

Brad