Results 1 to 5 of 5

Thread: excute code from form2 in form 1

  1. #1

    Thread Starter
    New Member pyromaniac4382's Avatar
    Join Date
    Jun 2006
    Posts
    8

    excute code from form2 in form 1

    So i am trying to make a basic title screen and have made two form2 form 1 has all of the controll to start game go to instuctions (ect) form 2 has a text box that will display some of the working of what is going on in the game and has text inside the text box.

    What i am trying to do is after form 1 get through its code ... ( you click a button and it hides form 1 and shows form 2)... i want it to execute form2 code which is a sub prosedure that alligns the text to center in text box1.


    This is my code so far:

    CODE for form 1:

    Public Class Form1

    Private Sub button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button1.Click
    Form2.Show()
    Me.Hide()
    End Sub


    End Class


    CODE for form 2:

    Public Class Form2


    Sub alligntext()
    RichTextBox1.Text = HorizontalAlignment.Center
    End Sub


    End Class

  2. #2
    Hyperactive Member ZaNi's Avatar
    Join Date
    Jun 2006
    Location
    Australia
    Posts
    360

    Re: excute code from form2 in form 1

    You'll want to write a routine for the Form2_Load event. You can access this event easily by double-clicking on form2 in the form2 designer.

  3. #3
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: excute code from form2 in form 1

    Read the Forms in VB.NET tutorial in my signature.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  4. #4

    Thread Starter
    New Member pyromaniac4382's Avatar
    Join Date
    Jun 2006
    Posts
    8

    Re: excute code from form2 in form 1

    which one the home and learn because there are so many in your signature .... ><

  5. #5
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: excute code from form2 in form 1

    Knock, knock.
    Quote Originally Posted by jmcilhinney
    Read the Forms in VB.NET tutorial in my signature.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

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