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

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
 
G

Guest

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
 
T

thomasp

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
 
C

Cor Ligthert [MVP]

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
 
T

thomasp

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
 
T

thomasp

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top