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 ()
.ShowDialog()
frmMain As frmMain = New frmMain
frmMain.lblText.Text = "Hello please help"
.Show()
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