954,517 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Button1.Text = "Hello World"

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?

Denxerator
Newbie Poster
8 posts since Jul 2009
Reputation Points: 10
Solved Threads: 0
 

if you use vb6 then try it easily:

Private Sub Command1_Click()
Command1.Caption = "Hello World"
End Sub
abu taher
Practically a Posting Shark
845 posts since Jul 2008
Reputation Points: 14
Solved Threads: 78
 

Not working, I'm using Microsoft Visual Basic 2008 Express edition

Denxerator
Newbie Poster
8 posts since Jul 2009
Reputation Points: 10
Solved Threads: 0
 

Try to use Me:
Me.Button1.Text = "Hello World"

hussain3874
Newbie Poster
3 posts since Sep 2009
Reputation Points: 10
Solved Threads: 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.

TomW
Posting Whiz
343 posts since Sep 2009
Reputation Points: 84
Solved Threads: 48
 

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.

Ryshad
Nearly a Posting Virtuoso
1,307 posts since Aug 2009
Reputation Points: 512
Solved Threads: 246
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You