How to change label.text from on form in another form

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello,
How do i change a label in another form from another one?
in vb6 i use to do this:

form1:
private sub label1_change()
form2.label1.caption="hgghjghjg"
' and the label in form2 is changed by the value i wanted
end sub

How do i do the same in vb.net???
Thanks, for help
best regars
Luis
 
Luis said:
Hello,
How do i change a label in another form from another one?
in vb6 i use to do this:

form1:
private sub label1_change()
form2.label1.caption="hgghjghjg"
' and the label in form2 is changed by the value i wanted
end sub

How do i do the same in vb.net???
Thanks, for help
best regars
Luis
how is it setup? Is form2 a member of Form1? If so on form2 make a
Property to do it for you.

Form2:
public property SetLabel1 as String
get
return label1.text
end get
set (value as string)
label1.text = value
end set
end property
 
I just recently needed to do the something similar. I needed to update a
progress bar and a label on a form while the code was executing in a
function in a separate module. I may have not done it the correct way, but
it seems to work. I declared a Public variable for the label and the
progress bar.

in the module

Public objProgressBar as progressbar
Public objLabel as Label


on the form the progress bar and label or located I assigned each to the
Public Variables

objProgressBar = me.theProgressBar
objLabel = me.theLabel

that made the properties of the two available throughout the project

objLabel.text = "Whatever you wish, from where ever you wish"


Worked for me.


Thomas
 
Luis,

It depends heavily what kind of form that you use in this situation.
MDI,
ShowDialog
or
Show.

Where it is with the ShowDialog the most easiest in a correct OOP way to do.

Therefore can you tell what is your reason for this.

Cor
 
I just recently needed to do the something similar. I needed to update a
progress bar and a label on a form while the code was executing in a
function in a separate module. I may have not done it the correct way, but
it seems to work. I declared a Public variable for the label and the
progress bar.

in the module

Public objProgressBar as progressbar
Public objLabel as Label


on the form the progress bar and label or located I assigned each to the
Public Variables

objProgressBar = me.theProgressBar
objLabel = me.theLabel

that made the properties of the two available throughout the project

objLabel.text = "Whatever you wish, from where ever you wish"


Worked for me.


Thomas
 
I just recently needed to do the something similar. I needed to update a
progress bar and a label on a form while the code was executing in a
function in a separate module. I may have not done it the correct way, but
it seems to work. I declared a Public variable for the label and the
progress bar.

in the module

Public objProgressBar as progressbar
Public objLabel as Label


on the form the progress bar and label or located I assigned each to the
Public Variables

objProgressBar = me.theProgressBar
objLabel = me.theLabel

that made the properties of the two available throughout the project

objLabel.text = "Whatever you wish, from where ever you wish"


Worked for me.


Thomas
 
Back
Top