Re: Form Reference Question (Getting Back Your Visual Basic 6.0 Goodies)



| As long as myModuleCode has a reference to "Form1" then you can do this.
| You'll probably have to send in a reference to form1 to form2.
| Something like:
|
| public class form2
| dim RefToForm1 as Form1
| sub new(F1 as Form1)
| mybase.new()
| RefToForm1 = F1
| end sub
| sub myModuleCode()
| RefToForm1.Visible = False
| .....
| RefToForm1.Visible = False
| end sub
| End class
|
| note that this way of doing it causes you to create Form2 this way:
|
| From inside Form1 somewhere...
| dim F2 as new Form2(Me) 'This passes in the reference of form1 to form2
|
| Hope it helps
| Chris

Hi, Chris ... it may help ... although I sense potential problems in more complex programs ...

For example, Form1 opens Form2, Form2 calls the sub "chris" in Module1, "chris" hides Form1,
then, later, Form1 opens Form3, Form3 calls the sub "chris" in Module1, "chris" hides Form1.

This all appears to force far to much form to form to module or class communication.

Since ALL of these code units are compiled together, it would be so much
easier if one could say from ANYWHERE, in a simple syntax, something like

"Form1".Visible = <truth value>

It would have been so much easier if VB.NET had included the VB6 Forms collection.

g.


.



Relevant Pages

  • Re: How can I throw out (handle) an ENTER keypress for an AcceptButton?
    ... that Form1 was receiving a KeyUp from a key press that occurred on Form2. ... My app starts with Form1 which has a textbox on it. ... KeyUp event of the textbox for that. ... > Private Sub Button1_Click(ByVal sender As System.Object, ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Shared Method Problem With "Global" Storage
    ... a routine in Module1 which then calls code back in Form1 ... ButtonHasBeenClicked but the reference to ButtonHasBeenClicked ... instance member of a class from within a shared method or shared ... In a shared Sub, you can not access an instance field withouth ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Err Object Anomaly Bug in VB6+SP5 and How to Reproduce
    ... - Form1 is destroyed and reloaded. ... subclass procedure, but I am accessing them in event procedures called by ... Private Sub Form_Load ... Private Sub Form_Click ...
    (microsoft.public.vb.bugs)
  • Re: Instanzen von identischen Formen ?
    ... Projekt mit ein Form: Form1 ... Private Sub Main() ... End With ... With FormB ...
    (microsoft.public.de.vb)
  • Re: Converting BMP file to JPG file
    ... Public Class Form1 ... Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) ... The following procedure is required by the Windows Form Designer ...
    (microsoft.public.dotnet.framework.compactframework)