I came across this piece of code once while trying to solve a similar problem. See if this helps.
Private Sub releaseObject(ByVal obj As Object)
Try
System.Runtime.InteropServices.Marshal.ReleaseComObject(obj)
obj = Nothing
Catch ex As Exception
obj = Nothing
Finally
GC.Collect()
End Try
End Sub
According to the person who posted it, it is supposed to release the passed object then force garbage collection to run to reclaim the space.
Reverend Jim
Illigitimae non carborundum
3,743 posts since Aug 2010
Reputation Points: 585
Solved Threads: 470
Skill Endorsements: 33
Public Class Form1
Public mytextbox as New TextBox
.
.
.
End Class
Public Class Form2
.
.
.
MsgBox(Form1.mytextbox.Text)
.
.
.
End Class
Reverend Jim
Illigitimae non carborundum
3,743 posts since Aug 2010
Reputation Points: 585
Solved Threads: 470
Skill Endorsements: 33
Same thing. Declare it at the class level and it will have class scope. If you are only using it inside the class then you can make it private.
Reverend Jim
Illigitimae non carborundum
3,743 posts since Aug 2010
Reputation Points: 585
Solved Threads: 470
Skill Endorsements: 33
Add a "cool" Parameter to your Sub.
Sub two(byval selCoolTextBox as TextBox)
'How to access TB here ?? or from anywhere in app domain
msgbox(selCoolTextBox.text)
End Sub
And call it as:
private sub someBtn.Click
two(TB)
End Sub
codeorder
Postaholic
2,124 posts since Aug 2010
Reputation Points: 256
Solved Threads: 387
Skill Endorsements: 8