Changing Label text property on another form, post #2

M

Mike Johnson

Thanks for the quick responses. I'm having trouble understanding. I've
included the code I using. perhaps someone can tell me what I'm doing wrong.
My original question was,

I'm new to VB.Net and programming. I just bought VB.Net Standard I'm working
on a small program for work. I've created two forms the first is named
Forms1 and the second is named SettingsForm. On forms1 I've placed two
components a NotifyIcon and FileSystemWatcher. I created a event handler
called onchanged which responds to file being created in a certain
directory. Now my problem is I can't figure out how to change the label.text
property on form two (SettingsForm) from the Event Handler. Can someone
please help me? Thanks in advance.


Maybe some more info would help. Both forms are separate. I didn't create
one from the other. I think that's what someone was asking.

The following code is on the first form, called Form1

Public Sub FileSystemWatcher1_Created(ByVal sender As System.Object, ByVal e
As System.IO.FileSystemEventArgs) Handles FileSystemWatcher1.Created

Beep()

'Display SettingsForm dialog if it is not already displayed.

If mSettingsForm Is Nothing Then

mSettingsForm = New SettingsForm

mSettingsForm.ShowDialog()

Else

If mSettingsForm.Visible = False Then

mSettingsForm.Visible = True

End If

mSettingsForm.Activate()

End If

'Update label on Settings Form.

mSettingsForm.UpDateLabel("This is a test")

End Sub

The code below is on the second form called SettingsForm.

Public Sub UpDateLabel(ByVal LabelText As String)

Label1.Text = LabelText

End Sub
 
C

Cor Ligthert

Hi Mike,

You use the structure of a normal show while doing a showdialog

The most easy way for a showdialog is in Form1

dim frm2 as new form2
frm2.Labeltext = whatever String in form1
frm2.showdialog(me)
frm2.dispose

Labeltext is a public string which you mostly set under the form designer
code as
Public Labeltext as String

That

Label1.text = Labeltext stays

I hope that helps?

Cor
 
H

Herfried K. Wagner [MVP]

* "Mike Johnson said:
Thanks for the quick responses. I'm having trouble understanding. I've
included the code I using. perhaps someone can tell me what I'm doing wrong.
My original question was,

Why not stay in the original thread?
 

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