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

Update Parent Window

P: n/a
I have a simple form with a text box in it that I'm using to show the
history of events in my program. My main form references a bunch of class
modules to execute various routines. I would like these routines to be able
update the textbox in the main form but am at a loss on how to do it.
(example below)

I'm sure this is an easy solution.....I just don't spend enough time working
in the vb.net world.

Thanks.

-----------------------------------------------------------
Example:

Main Form name - Engine.vb and has a textbox called boxHistory

Private Sub Engine_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim myCode As New CommonCode()
boxHistory="Hello"
myCode.DoSomething
End Sub
The class file is called CommonCode.vb with a routine called DoSomething

Public Sub DoSomething()

'End result would be to update boxHistory
boxHistory.text &= " World"
End Sub

Nov 20 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Rob,

There are many solutions to this problem here are a couple:

(1) Pass the text box to each of your methods
(2) Define a public variable in a module that references your main form
The main form could contain a method Log(ByVal message As String)
All of your class method could then call the public variable.Log
method
e.g:

Module Start
Public mLogForm As MainForm

Public Sub Main()
Dim f as New MyMainForm

mLogForm = f
f.ShowDialog

End Sub

End Module

Public Class Stuff

Public Sub DoSomething()
Start.mLogForm.Log("Hello World")
End Sub
End Class

Dan

"Rob T" <RT*********@DONTwalchemSPAM.com> wrote in message
news:Or**************@TK2MSFTNGP10.phx.gbl...
I have a simple form with a text box in it that I'm using to show the
history of events in my program. My main form references a bunch of class
modules to execute various routines. I would like these routines to be able update the textbox in the main form but am at a loss on how to do it.
(example below)

I'm sure this is an easy solution.....I just don't spend enough time working in the vb.net world.

Thanks.

-----------------------------------------------------------
Example:

Main Form name - Engine.vb and has a textbox called boxHistory

Private Sub Engine_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim myCode As New CommonCode()
boxHistory="Hello"
myCode.DoSomething
End Sub
The class file is called CommonCode.vb with a routine called DoSomething

Public Sub DoSomething()

'End result would be to update boxHistory
boxHistory.text &= " World"
End Sub


Nov 20 '05 #2

P: n/a
Thanks. I'm not really sure how you're cross referencing everything, but I
got something to work. I create the module with a public variable called
"log", then reference this variable from my other class modules. I have an
existin timer event running so I justtrigger off of that and make the
textbox equal to the Log variable.

.....good enough for my stupid program. ;-)

"solex" <so***@nowhere.com> wrote in message
news:uS**************@TK2MSFTNGP09.phx.gbl...
Rob,

There are many solutions to this problem here are a couple:

(1) Pass the text box to each of your methods
(2) Define a public variable in a module that references your main form
The main form could contain a method Log(ByVal message As String)
All of your class method could then call the public variable.Log
method
e.g:

Module Start
Public mLogForm As MainForm

Public Sub Main()
Dim f as New MyMainForm

mLogForm = f
f.ShowDialog

End Sub

End Module

Public Class Stuff

Public Sub DoSomething()
Start.mLogForm.Log("Hello World")
End Sub
End Class

Dan

"Rob T" <RT*********@DONTwalchemSPAM.com> wrote in message
news:Or**************@TK2MSFTNGP10.phx.gbl...
I have a simple form with a text box in it that I'm using to show the
history of events in my program. My main form references a bunch of class modules to execute various routines. I would like these routines to be

able
update the textbox in the main form but am at a loss on how to do it.
(example below)

I'm sure this is an easy solution.....I just don't spend enough time

working
in the vb.net world.

Thanks.

-----------------------------------------------------------
Example:

Main Form name - Engine.vb and has a textbox called boxHistory

Private Sub Engine_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim myCode As New CommonCode()
boxHistory="Hello"
myCode.DoSomething
End Sub
The class file is called CommonCode.vb with a routine called DoSomething

Public Sub DoSomething()

'End result would be to update boxHistory
boxHistory.text &= " World"
End Sub



Nov 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.