Reputation: 11
We would like to display the name of the computer being used on our application without having to click on a label or use of a messege box.
Private Sub Label2_Click(sender As Object, e As EventArgs) Handles Label2.Click
Label2.Text = My.Computer.Name
End Sub
The code above works but only when you click on the label.
How do we get it to just display as plan text.
Upvotes: 0
Views: 98
Reputation: 234
Add a constructor to the window containing the label and assign the text in there.
Public Sub New()
' This call is required by the designer.
InitializeComponent()
Label1.Text = My.Computer.Name
End Sub
Upvotes: 0
Reputation: 2568
Private Sub Form1_Activated(sender As Object, e As System.EventArgs) Handles Me.Activated
Label1.Text = My.Computer.Name
End Sub
Upvotes: 1