Thursday, November 26, 2015

Visual Basic Sample Activities: Change the value of form1

How to add form1 with form2 that enters your name and change the value of the blank label of form1

1.      Add a form, Form1 to your application

2.      Change the text properties of the button to 'enter your name’.

3.      Double click the ‘Enter your name button and insert the given code below.


Me.Hide()
Form2.Show()

4.    Add a new Windows Form, Form2, two buttons, one label, and a text box to Form2.


5.    Change the text properties of the buttons to OK and Cancel respectively. Change the text properties of the label to 'Enter your name:


6.      Double click the ‘ok’ button and insert the given code.

Form1.Label1.Text = TextBox1.Text
        Form1.Show()
        Me.Hide()

7.      Double click the ‘cancel button and insert the given code.

TextBox1.Text = ""


8.      Run your program.








No comments:

Post a Comment