Results 1 to 12 of 12

Thread: Changes from VB6 to VB.NET

  1. #1

    Thread Starter
    New Member
    Join Date
    Dec 2000
    Location
    Molde, Norway
    Posts
    13

    Unhappy Changes from VB6 to VB.NET

    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? 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!!!

  2. #2
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    VB Code:
    1. dim mform1 as new form1
    2. dim mform2 as new form2
    3.  
    4. mform1.text="lol"
    5. 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

  3. #3

    Thread Starter
    New Member
    Join Date
    Dec 2000
    Location
    Molde, Norway
    Posts
    13

    Thihihi!

    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?

  4. #4
    Hyperactive Member
    Join Date
    Feb 2002
    Posts
    261

    Re: Thihihi!

    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?
    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?

  5. #5
    Frenzied Member
    Join Date
    Nov 2003
    Posts
    1,489
    Originally posted by PT Exorcist
    VB Code:
    1. dim mform1 as new form1
    2. dim mform2 as new form2
    3.  
    4. mform1.text="lol"
    5. 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.

  6. #6
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    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.
    \m/\m/

  7. #7
    Frenzied Member DevGrp's Avatar
    Join Date
    Nov 2001
    Location
    Charlotte, NC
    Posts
    1,256
    Originally posted by PT Exorcist
    VB Code:
    1. dim mform1 as new form1
    2. dim mform2 as new form2
    3.  
    4. mform1.text="lol"
    5. 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.
    VB Code:
    1. Public Property MyText() as String
    2.      Get
    3.           Return TextBox1.Text
    4.      End Get
    5. End Property

  8. #8

    Thread Starter
    New Member
    Join Date
    Dec 2000
    Location
    Molde, Norway
    Posts
    13
    Think I've solved the problem by now:

    In Form1 I've written this:
    VB Code:
    1. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    2.         Dim frm As New Form2(Me)
    3.         frm.Show()
    4.     End Sub

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

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

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

    This works.... I think...

  9. #9
    Frenzied Member
    Join Date
    Nov 2003
    Posts
    1,489
    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.

  10. #10

    Thread Starter
    New Member
    Join Date
    Dec 2000
    Location
    Molde, Norway
    Posts
    13
    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.

  11. #11
    Addicted Member Hole-In-One's Avatar
    Join Date
    Mar 2003
    Location
    Minnesota
    Posts
    195
    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.

  12. #12
    ex-Administrator brad jones's Avatar
    Join Date
    Nov 2002
    Location
    Indianapolis
    Posts
    6,614
    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
    Have you given out your reputation points today? Select the Rate This Post link to give points for good posts!
    -------------------------------------------------------------
    Brad! Jones
    Lots of Software, LLC
    (I wrote: C Programming in One Hour a Day) (Dad Jokes Book) (Follow me on Twitter)

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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width