Hi,
I have a small big problem with classes and objects..
In VB6 I create a new project, DLL ActiveX; I leave the default name
("progetto1" - in italian); then I rename the class module in "cls1"; I
save the class module with name "cls1.cls" and the project file with
name "clsT.vpb"; and then I add these few lines to the class module:
Private Sub Class_Initializ e()
Debug.Print "Class_Initiali ze()"
End Sub
Private Sub Class_Terminate ()
Debug.Print "Class_Terminat e()"
End Sub
Public Sub ini()
Debug.Print "INI"
End Sub
I set "5 - Multiuse" as Instancing for cls1, save again and run the
project.
VB.NET; I create a new project "windows application" type; I add a
button to the main form; I add as reference that "progetto1" saved
before (its simple since you can add a vpb project without compiling
it!); for the button click event I add the following:
Dim k As Progetto1.cls1
k = New Progetto1.cls1
k.ini()
k = Nothing
Save and run the VB.NET project too.
Now, pressing the button on the form I aspect to see in the "debug
window" of VB6: "Class_Initiali ze()", then "INI", then
"Class_Terminat e()", but that does not happen! Only
"Class_Initiali ze()" and "INI" are printed, while "Class_Terminat e()"
is only printed when I close the form!
Can someone explain me why this happens?
Sorry for my english...
I forgot to say that I use VB.NET 2003...
Grazie,
D. 4 1319
a) this is a .net newgroup, not a vb6 one
b) your problem is caused the "multiuse instancing"
nokia33948 wrote:
Hi,
I have a small big problem with classes and objects..
In VB6 I create a new project, DLL ActiveX; I leave the default name
("progetto1" - in italian); then I rename the class module in "cls1"; I
save the class module with name "cls1.cls" and the project file with
name "clsT.vpb"; and then I add these few lines to the class module:
Private Sub Class_Initializ e()
Debug.Print "Class_Initiali ze()"
End Sub
Private Sub Class_Terminate ()
Debug.Print "Class_Terminat e()"
End Sub
Public Sub ini()
Debug.Print "INI"
End Sub
I set "5 - Multiuse" as Instancing for cls1, save again and run the
project.
VB.NET; I create a new project "windows application" type; I add a
button to the main form; I add as reference that "progetto1" saved
before (its simple since you can add a vpb project without compiling
it!); for the button click event I add the following:
Dim k As Progetto1.cls1
k = New Progetto1.cls1
k.ini()
k = Nothing
Save and run the VB.NET project too.
Now, pressing the button on the form I aspect to see in the "debug
window" of VB6: "Class_Initiali ze()", then "INI", then
"Class_Terminat e()", but that does not happen! Only
"Class_Initiali ze()" and "INI" are printed, while "Class_Terminat e()"
is only printed when I close the form!
Can someone explain me why this happens?
Sorry for my english...
I forgot to say that I use VB.NET 2003...
Grazie,
D.
Try changing to the following:
Dim k As Progetto1.cls1
k = New Progetto1.cls1
k.ini()
Marshal.Release ComObject (k)
HTH,
--
Tom Shelton
Tom Shelton wrote:
Try changing to the following:
Dim k As Progetto1.cls1
k = New Progetto1.cls1
k.ini()
Marshal.Release ComObject (k)
HTH,
--
Tom Shelton
Thanks you very much Tom. That solved: both the problema and my
headache!
Rergards,
D. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: vrillusions |
last post by:
I've been using functions since I first started using php, but I've been
hearing more and more about classes, which I never really looked at that
much. I understand the whole OO programming aspect, but are there any
advantages to having classes as opposed to just functions? I've heard that
the classes are better because they only load the...
|
by: David MacQuigg |
last post by:
Playing with Prothon today, I am fascinated by the idea of eliminating
classes in Python. I'm trying to figure out what fundamental benefit
there is to having classes. Is all this complexity unecessary?
Here is an example of a Python class with all three types of methods
(instance, static, and class methods).
# Example from Ch.23,...
|
by: Bo Peng |
last post by:
Dear Python group:
I am planning on an application that involves several complicated C++
classes. Basically, there will be one or two big data objects and some
"action" objects that can act on the data. I would like to use a script
language to control the interaction between these c++ objects.
I become interested in Python since it can...
|
by: Marco |
last post by:
Howdy!
Given:
public abstract class A {
public abstract int A1(int i);
private class B {
private int B1(int i) {
int j;
|
by: Kevin Prichard |
last post by:
Hi all,
I've recently been following the object-oriented techiques discussed
here and have been testing them for use in a web application. There is
problem that I'd like to discuss with you experts.
I would like to produce Javascript classes that can be "subclassed"
with certain behaviors defined at subclass time. There are plenty of...
| |
by: Dave |
last post by:
Please - anyone that can help.
I am getting confusing results while trying to expose a collection from a
web service.
I have a webservice in which a web method accepts a collection as a
parameter and returns an array of datasets. The collection consists of
database connection objects.
Based on the simple hierarchy below, you can see...
|
by: weaknessforcats |
last post by:
Handle Classes
Handle classes, also called Envelope or Cheshire Cat classes, are part of the Bridge design pattern. The objective of the Bridge pattern is to separate the abstraction from the implementation so the two can vary independently.
Handle classes usually contain a pointer to the object implementation. The Handle object is used...
|
by: stormogulen |
last post by:
Hi!
I'm having some problems figuring out how to organize the different
tiers of an application using a webservice.
The bottom layer is the DAL, and some of the objects in the DAL, I
would like to send via a webservice. That is no problem, just
reference the DAL from the webservice.
Now in the business layer I am calling methods on the...
|
by: Immortal Nephi |
last post by:
First class is the base class. It has two data: m_Base1 and m_Base2.
Second class and third class are derived classes and they are derived
from first class. m_Base1 and m_Base2 are inherited into two derived
classes.
Second class has its own m_Base1 and m_Base2 and third class does the
same. I am curious. How can second class and third...
|
by: =?Utf-8?B?QmV0aA==?= |
last post by:
Hello.
I'm trying to find another way to share an instance of an object with other
classes.
I started by passing the instance to the other class's constructor, like this:
Friend Class clsData
Private m_objSQLClient As clsSQLClient
Private m_objUsers As clsUsers
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
| |
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...
| |