Update Parent Window

  • Thread starter Thread starter Rob T
  • Start date Start date
R

Rob T

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
 
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
 
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. ;-)
 
Back
Top