Online Franz Tech Online Franz Tech - 3 years ago 176 Question

Is it possible to change the text of a label in another form without using .Show() or .ShowDialog

I have a problem on

My question is if it is possible to change the text of a Label without using

frm.Show ()

Example :

frmMain As frmMain = New frmMain
frmMain.lblText.Text = "Hello please help"

without using a
since it is already shown in a panel :

Answer Source

Yes, it is possible.

What Plutonix said in the comment, I guess is use the label in another form which already exists instead of making a new one.

For example, add a label1 in NewForm1 while designing the form.

Then, in Form1, you can do this:

NewForm1.label1.text = "Your text here"

Otherwise, if you don't want to put a label already in the design time, you can add it like this:

  Dim NewLabel1 As New Label
    With NewLabel1
        'add properties here
        .Text = "your text"
        .Parent = Me  'set the parent of the label as new form
        .Location = New Point(1, 1)
        'other properties here
    End With
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download