Solved

ActiveX exe start up

Posted on 2000-04-09
14
148 Views
Last Modified: 2010-05-02
In an ActiveX project you typically start it at the sub Main (), but if you leave that empty - where in the code would the program start.
0
Comment
Question by:tyy8
  • 5
  • 4
  • 2
  • +2
14 Comments
 
LVL 32

Expert Comment

by:Erick37
ID: 2698854
Private Sub Class_Initialize()
0
 
LVL 1

Expert Comment

by:sadcock
ID: 2698970
In whatever is specified in the program properties screen on the general tab.  Look for the startup object selection.


-Scott
0
 
LVL 14

Expert Comment

by:wsh2
ID: 2699004
As with any project.. it is always best to start from a Sub Main module and then Navigate from there.. <smile>.

Sub Main, is a great place to define any/all Global variables, functions, and/or subroutines that you have all in one place. It is a great place to put once and done application open and close processing routines, disencumbering you from coding the same in various other Forms.. which can be a pain to locate if you ever have to go back to your code.

All in all, it is a matter of style.. but I prefer to ALWAYS use a Sub Main.. <smile>.
0
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
LVL 10

Accepted Solution

by:
caraf_g earned 50 total points
ID: 2699377
Remember though that this is an ActiveX .exe

You don't start an activeX .exe, a program that *uses* it does.

Having a Sub Main only makes sense if you are using a thread pool with a single thread. The reason is that Sub Main is only executed the very first time any objects from your activeX .exe are instantiated. Even if you set the threading model to Thread per Object.

If you're using a Sub Main to set your globals in the latter threading model, it will work fine the first time around, but not after.

In cases of ActiveX .exes I would actually advise very much against using a Sub Main.
0
 

Author Comment

by:tyy8
ID: 2700631
caraf -

But since it's an exe, it should have a new instantiation every time a user calls it (unlike a dll). So the sub main would get sparked for each user.
0
 

Author Comment

by:tyy8
ID: 2700635
Sadcock -

THe startup property is set to (none) in the dropdown box.
0
 

Author Comment

by:tyy8
ID: 2700639
Erick37 -

WHat if there is more then one class in the project, which class' initialize event would get fired?
0
 
LVL 10

Expert Comment

by:caraf_g
ID: 2700670
tyy8

NO. Try it and see.
0
 
LVL 32

Expert Comment

by:Erick37
ID: 2700727
Class_Initialize is fired for every class that you create an instance of.

Dim c as New Class1
'The Intitalize event for Class1 is
' fired prior to the .test call.
c.test
set c = Nothing
0
 
LVL 10

Expert Comment

by:caraf_g
ID: 2700768
Exactly. If you specify a sub main, this sub is executed the first time ANY object in your ActiveX .exe is instantiated.

As long as the ActiveX .exe remains loaded, this sub won't happen again, no matter *how* many subsequent objects from the ActiveX .exe you load.
0
 

Author Comment

by:tyy8
ID: 2701078
Oops, yeah - your right. I guess I was thinking of the class being set to singleuse - and that make a new exe everytime.

Okay, I think I'm cleared up on this point. Who wants the points?
0
 
LVL 14

Expert Comment

by:wsh2
ID: 2701101
caraf_g:
sub main.. <hat in hand>.. I stand corrected and defer to your wisdom.. <smile>
0
 
LVL 10

Expert Comment

by:caraf_g
ID: 2703147
tyy8, just give the points by accepting whosever comment you deemed most appropriate to your question.
0
 

Author Comment

by:tyy8
ID: 2708462
Caraf_g:

Your comments were the most enlightening, thanks to everybody, so I'll send the points over to you.

Thanks
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
using web browser with BING 40 119
How to measure sizes and angles in scanned images ? 3 63
Spell Check in VB6 13 112
how to Classify of email (pdf attachments) 7 34
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now