By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,086 Members | 1,875 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,086 IT Pros & Developers. It's quick & easy.

Changing Label text property on another form, post #2

P: n/a
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
Nov 20 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Hi Mike,

Can we chat via Messager...? If you have no objections, use my e-mail
address (remove online). I would like to compare notes with you, if you
don't mind, Messager is quicker than NG....

You may want to read the following MSDN article.
http://msdn.microsoft.com/library/de...adingToNET.asp

Thanks.
"Mike Johnson" <jo*****@bellsouth.net> wrote in message
news:OJ**************@TK2MSFTNGP09.phx.gbl...
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

Nov 20 '05 #2

P: n/a
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
Nov 20 '05 #3

P: n/a
* "Mike Johnson" <jo*****@bellsouth.net> scripsit:
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?

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.