JavaScript Editor JavaScript Editor     JavaScript Debugger

Previous Section Next Section

Main Page

Setting a Button's Caption

You use a button's Text property (formerly the Caption property in VB6 and before) to set its caption. This property is available at both design time and run time. After you add a button to a form, you set its caption by placing the appropriate text in the Text property in the properties window:

Private Sub Button1_Click(ByVal sender As System.Object, _
    ByVal e As System.EventArgs) Handles Button1.Click
    Button1.Text = "You clicked me!"
End Sub

It's useful to be able to change the caption of buttons. For example, if a button's caption reads "Connect to Internet", then, when connected, you could change the button's caption to "Disconnect from Internet", and disconnect from the Internet when the button is clicked.

Previous Section Next Section

JavaScript Editor Free JavaScript Editor     JavaScript Editor