declare global object from within a procedure?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Is there a way to create an instance of an object - say a windows form -
from within a sub such that the object has class level scope?
 
mark said:
Is there a way to create an instance of an object - say a windows form -
from within a sub such that the object has class level scope?
not sure I understand the question. I think you are asking this:

Public Class MyClass

Dim F as Form

private sub DoSomething()
F = new MyForm
End Sub

End Class

Now F has class level scope.
 
I think so

What I am looking for is a way to re-initialize an instance of form2,
resetting all of the controls (datagrids in particular) to that state they
were in when the instance was first created.

It appears that using form2.datagrid1.datasource=nothing is a very time
consuming task.
mark b
 
Mark,

The normal way for this is declaring your form not gobaly
Private myForm as Form2

However forever in the procedure

dim myForm as New Form2
myForm.Show
And to see if it is still alive before that

if myForm.IsDisposed = false

I hope this helps,

Cor
 
I think this helps. I guess my trouble has been not understanding the
difference between dim myform as new form2 and dim myform as form2.

I am still shaky on the distinction but it looks like as form2 is a simple
declaration and as new form2 is a creation of an instance.

Is this right?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top