Visual Basic .NET单击按钮后,文本框中的Hello World
示例
拖动1文本框和1按钮
双击按钮1,您将被转到Button1_Clickevent
Public Class Form1 Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click End Sub End Class
输入您要定位的对象的名称,在本例中为textbox1。.Text是要在文本上添加文字的属性。
PropertyTextbox.Text,getsorsetsthecurrenttextintheTextBox。现在,我们有Textbox1.Text
我们需要设置它的值,Textbox1.Text所以我们将使用=符号。我们要输入的值Textbox1.Text是HelloWorld。总体而言,这是为HelloWorld赋予值的总代码Textbox1.Text
TextBox1.Text = "Hello World"
将该代码添加到的clickedevent中button1
Public Class Form1 Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click TextBox1.Text = "Hello World" End Sub End Class