0
Public Class Form1
    Private Sub Button1_Click(ByVal sender As  _
                               System.Object, ByVal e As System.EventArgs)
        -
        Handles Button1.Click

        Button1.Text = "Hello World"
    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub
End Class

The name of the button isn't changing to Hello World... Anyone can correct this?

5
Contributors
5
Replies
6
Views
8 Years
Discussion Span
Last Post by Geekitygeek
0

if you use vb6 then try it easily:

Private Sub Command1_Click()
Command1.Caption = "Hello World"
End Sub
0

Your syntax is correct. You do not have the coding in the Form_Load event, you have it in the button click event, you must click the button before you should see the changes.

Edited by TomW: n/a

0

You said the buttons 'name' doesnt change, but you are assigning a value to its Text property. The Text property is the string shown on the button, but the buttons name is used to identify it within the application.

The code you have written will change the text on the button when you click it. Its name will still be Button1.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.