Reputation: 15
I want my button1
to change the text of my form1
from "My Application name" to "My Application name2" by the click of a button.
What I've tried:
form1.text = (textbox1.text)
But no luck.
Any Help?
Upvotes: 0
Views: 5260
Reputation: 535
When you say change "Name" you are talking about changing the word that represents the form throughout the coding. This means it can ONLY HAVE ONE NAME because it woudl be a chaos if it had more than one.
When you say change "Text" you are talking about the "Title" of the form. The text that shows up there in the left upper corner.
To change the Name you just need to click the form on the designer and then go to properties and scroll down until you find the Name option. You can change Text the same way or programatically writing:
Me.Text = "MyApplicationName 2"
Hope it helps.
Upvotes: 0
Reputation: 7076
You cannot can change the form name at run time. The name of a Form can be anything you want, but it must stay the same throughout. I can't imagine however why would you ever want to change the name in runtime as its not visible to the users. The form's caption on the other hand is a completly different thing, adressed in @matzone's answer.
Upvotes: 1
Reputation: 5719
If you meant about Main Form caption/text .. It has to be work with
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Me.Text = Textbox1.Text
End Sub
Upvotes: 2