473,396 Members | 1,990 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.

unsure of what I'm doing & need info


Been messing with vb6 for awhile, but am unfamiliar with 2005 & oop.

in a sub i'm using dim mydialog as openfiledialog
and the rest of the code follows.

everything works fine on the surface but....

My question is...should I use mydialog.dispose() before
exiting the sub, or will vb take care of this for me.
May 13 '07 #1
7 885
"Smitty" <ia*********@yahoo.comwrote in news:52988FBF-D182-4FAF-8031-
94**********@microsoft.com:
My question is...should I use mydialog.dispose() before
exiting the sub, or will vb take care of this for me.
..NET is a managed environment and most of the time you do not need to call
dispose.

Some people like to call it regardless.

In anycase, best to check the class documentation to see if .dispose is
required.

May 13 '07 #2
"Smitty" <ia*********@yahoo.comschrieb:
in a sub i'm using dim mydialog as openfiledialog and the rest of the code
follows.
everything works fine on the surface but....
My question is...should I use mydialog.dispose() before exiting the sub,
or will vb take care of this for me.
If you are showing the form by calling its 'ShowDialog' method, the form
doesn't get disposed automatically. Thus I'd recommend to dispose it by
hand. This can be done using a 'Using' block, which will guarantee that
'Dispose' is called:

\\\
Using f As New FooForm()
If f.ShowDialog() = ... Then
...
Else
...
End If
End Using
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

May 13 '07 #3
Herfried K. Wagner [MVP] wrote:
If you are showing the form by calling its 'ShowDialog' method, the form
doesn't get disposed automatically. Thus I'd recommend to dispose it by
hand. This can be done using a 'Using' block, which will guarantee that
'Dispose' is called:

And what about using me.dispose() method into the btnClose_Click of the
dialog form?

Marco / iw2nzm
May 13 '07 #4
Marco,

At the end of a manageged code class. Do nothing.

This does not mean that you don't see everything anymore it is done in its
best time.

Cor
"Marco Trapanese" <ma******************@libero.itschreef in bericht
news:iD*****************@twister2.libero.it...
Herfried K. Wagner [MVP] wrote:
>If you are showing the form by calling its 'ShowDialog' method, the form
doesn't get disposed automatically. Thus I'd recommend to dispose it by
hand. This can be done using a 'Using' block, which will guarantee that
'Dispose' is called:


And what about using me.dispose() method into the btnClose_Click of the
dialog form?

Marco / iw2nzm

May 13 '07 #5
"Marco Trapanese" <ma******************@libero.itschrieb:
>If you are showing the form by calling its 'ShowDialog' method, the form
doesn't get disposed automatically. Thus I'd recommend to dispose it by
hand. This can be done using a 'Using' block, which will guarantee that
'Dispose' is called:

And what about using me.dispose() method into the btnClose_Click of the
dialog form?
It's not necessary here. Simply follow the pattern I have shown.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

May 13 '07 #6
Herfried K. Wagner [MVP] wrote:
It's not necessary here. Simply follow the pattern I have shown.

Ok, thanks!

Marco / iw2nzm
May 14 '07 #7
Smitty wrote:
in a sub i'm using dim mydialog as openfiledialog and the rest of the
code follows.
everything works fine on the surface but....
Does openfiledialog have a Close() method?
If so call it, then check the documentation for that method as to
whether it calls Dispose for you.

Failing that ...

Does openfiledialog have a Dispose() method?
If so, call it.

The *convention* is that the Dispose method should release any
/unmanaged/ resources that the class makes use of. If you don't call
Dispose, then the chances are it will get called for you when the object
gets "Finalized", but that may not happen for quite some time (possibly
not until the entire process ends).

So - yes, I'd say you probably /ought/ to but, if Our Friends in Redmond
have done their jobs right, it shouldn't make any difference.

HTH,
Phill W.
May 17 '07 #8

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

Similar topics

5
by: Raju V.K | last post by:
I am developing a web site which requires a set og unique values be transferred between pages and server many times. There fore i decided to put the values in an array so that only one reference to...
4
by: Igor Fedorow | last post by:
Hello all, I have an XML file with an internal DTD which looks roughly like this: <?xml version="1.0"?> <!DOCTYPE root > ]> <root> <node>
1
by: Trevor Balcom | last post by:
I would like to do things when my object goes out of scope, like disconnect TCP/IP streams, serialize collections to files and so on... Would I implement my cleanup code in Dispose() ? Is this...
46
by: Keith K | last post by:
Having developed with VB since 1992, I am now VERY interested in C#. I've written several applications with C# and I do enjoy the language. What C# Needs: There are a few things that I do...
4
by: Kristoffer Arfvidson | last post by:
Im trying to get access to a table in codebehind, because the information in this table is different depending on what it says in the database... So, either I have to access it from codebehind,...
3
by: Alejandro Penate-Diaz | last post by:
Does anbody know how to clear the querystring between postbacks? tnx, alejandro.
0
by: Greg | last post by:
In my ASP.NET 1.1 Web application I have an HTTP Module that is a "global exception logger." that logs info about otherwise unhandled exceptions. It has logged the following exception 4 times...
4
by: John Boy | last post by:
Hi, Can anyone help. This is really doing my nut in. 3 years ASP exp. and now doing .DOT which is a step in the wrong direction. Basically I am left with the code of a guy who has left. When I...
3
by: John Nagle | last post by:
I have XML replies in a DOM which contain entity escapes, like "&amp;". What's the proper way to replace them with the ordinary characters? Preferably something that will work in most browsers? I...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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,...

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.