Online Franz Tech Online Franz Tech - 1 year ago 100
Vb.net Question

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

I have a problem on Vb.net

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

frm.Show ()
or
.ShowDialog()
.

Example :

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


without using a
.Show()
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