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
Posting Shark
1,167 posts since Aug 2010
Reputation Points: 253
Solved Threads: 159
Public Class Form1
Public mytextbox as New TextBox
.
.
.
End Class
Public Class Form2
.
.
.
MsgBox(Form1.mytextbox.Text)
.
.
.
End Class
Reverend Jim
Posting Shark
1,167 posts since Aug 2010
Reputation Points: 253
Solved Threads: 159
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
Posting Shark
1,167 posts since Aug 2010
Reputation Points: 253
Solved Threads: 159
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
Posting Virtuoso
1,913 posts since Aug 2010
Reputation Points: 255
Solved Threads: 384