473,396 Members | 1,975 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

declare global object from within a procedure?


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 b
Dec 7 '05 #1
4 1081
mark wrote:
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.
Dec 7 '05 #2
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
"I Don't Like Spam" wrote:
mark wrote:
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.

Dec 7 '05 #3
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

"mark" <ma**@discussions.microsoft.com> schreef in bericht
news:3D**********************************@microsof t.com...
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
"I Don't Like Spam" wrote:
mark wrote:
> 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.

Dec 8 '05 #4
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?
Dec 8 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: rick | last post by:
Noob problem. I prefer to keep all my scripts in an external '.js' file. I am currently loading the external '.js' file from the header. Problem is I would like to declare a global variable in the...
41
by: Miguel Dias Moura | last post by:
Hello, I am working on an ASP.NET / VB page and I created a variable "query": Sub Page_Load(sender As Object, e As System.EventArgs) Dim query as String = String.Empty ... query =...
3
by: Lennart | last post by:
Any thoughts on the following scenario anyone? During a performance test I discovered that the application asked one specific query extremely often. It turned out that this particular query...
20
by: teddysnips | last post by:
Weird. I have taken over responsibility for a legacy application, Access 2k3, split FE/BE. The client has reported a problem and I'm investigating. I didn't write the application. The...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.