[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Create Active-X control with methods that only run during run time Visual Basic 6

Posted on 2009-04-15
5
Medium Priority
?
316 Views
Last Modified: 2013-11-25
I am creating methods that read and write to a database. I don't want these methods to run during design time. I consider design time when the user embeds an active-x control in a container. I want these methods to run during run-time. What is happenning now is that when I embed the control into a container (excel vba editor), I get database connection errors because some database properties that I expect to be configured by the user aren't set. These methods are used to initialize the values on the control during run-time
0
Comment
Question by:adimit
  • 3
  • 2
5 Comments
 
LVL 39

Assisted Solution

by:abel
abel earned 2000 total points
ID: 24155905
(I thought I remember that VB6 contained a single method for finding that you are in design time or not. According to this post I was wrong: http://visualbasic.about.com/od/usevb6/l/blfaq0012a.htm, which shows a complex way of dealing with runtime/design time.)

However, I think what you are after is the Ambient.UserMode property, which is True for runtime and False for design time. Not sure whether you are creating a UserControl, I think so, because you talk of a container. If so, you can access this property through UserControl.UserMode.

-- Abel --
0
 

Author Comment

by:adimit
ID: 24160310
the above works fine if placed in ambientchanged event of the usercontrol. However when I press f5 to compile and run the .ocx, vb opens the .ocx in internet explorer. Internet explorer does not detect the ambient changed event. If I place the .ocx on a user form in excel then the ambientchanged event triggers.  It seems that this event only triggers on a user form, but I also need it to trigger ins omething like Internet Explorer as well. any thought?
0
 
LVL 39

Assisted Solution

by:abel
abel earned 2000 total points
ID: 24174937
Apparently you need to update. See this KB article from Microsoft: http://support.microsoft.com/kb/196219
0
 

Accepted Solution

by:
adimit earned 0 total points
ID: 24204565
I place the following code in the ambient changed event.

if usercontrol.ambient.usermode = true then 'enter code here
0
 
LVL 39

Expert Comment

by:abel
ID: 24205337
But that was what we used all the time, didn't we, that's what was in my first comment, at least, that's what it was supposed to be about. Sorry if I wasn't clear, but glad you have a solution now.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

873 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