Solved

VB5 - Active X Control - Attribute as a keyword???

Posted on 1998-01-28
8
289 Views
Last Modified: 2013-11-25
Hi,

I'm working my way through "Teach Yourself Database Programming with VB5 in 21 days" by SAMS Publishing.

Things being interesting because there are discrepancies between
what is printed on the page and what is supplied on the CD ROM.

So far I've managed to figure out what was wrong but this one has got me.

Day 12, building an Active X control to select from a list.

When I load up the CD rom version and compile it, it works.

When I load up the code I've typed in, it doesn't.

When I load up the ctl file into a text editor, I see that the CD
version has extra commands in the property definitions, like
Attribute DatabaseName.VB_ProcData.VB_Invoke_Property = "General;Data"

So, how is this command set, because when I type it in, VB5 doesn't
recognise it. How can I set it? I don't know if this is the cause of
why the typed in version doesn't work but it's a difference I've found.

Let me know if you need more details. TIA
0
Comment
Question by:alanlam
  • 5
  • 2
8 Comments
 
LVL 8

Expert Comment

by:mrmick
ID: 1453907
Click Project, References, and then check Microsoft DAO 3.5 Object Library, and add the missing code that you found on the CD-ROM.

0
 

Author Comment

by:alanlam
ID: 1453908
The Microsoft DAO 3.5 Object Library is already referenced.

The "attribute" bit of code from the program on the CD ROM doesn't appear when form is opened up using VB5.
It appears in the .ctl file when you open it up with notepad.

VB5 doesn't recognise the "attribute" keyword.
And, I can't find any mention of the attribute keyword in help files.
So somehow, those attributes are being set somewhere. Where?


0
 
LVL 8

Expert Comment

by:mrmick
ID: 1453909
I see, search help on "Procedure Attributes Command"

Click Tools, Procedure Attributes.


0
 

Author Comment

by:alanlam
ID: 1453910
Tools, Procedure Attributes looks promising but...
I'm a newbie to VB5 programming.

The .ctl code on the CD ROM (when opened with notepad) is :
Public Property Get DatabaseName() As String
Attribute DatabaseName.VB_ProcData.VB_Invoke_Property = "General;Data"
Attribute DatabaseName.VB_MemberFlags = "200"
    '
    DatabaseName = frmFind.Data1.DatabaseName
    '
End Property

Now, I can select property DatabaseName, but then I can't see anywhere to type in
DatabaseName.VB_ProcData.VB_Invoke_Property = "General;Data"

I'm sure we're getting somewhere, I just need more detailed instructions :-)

Supplementary side questions - what does this do, where can I find more info about it and why didn't the authors include it in the book? Is it very complicated or might have been set in a previous project when they renamed it?
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 6

Accepted Solution

by:
anthonyc earned 100 total points
ID: 1453911
This is not a command you can type in.  Using the Procedure Attributes command, you have your properties/methods RESEMBLE the common properties.  Making the DatabaseName property resemble the data controls databasename property allows your control to be a databound control.  This is not something you set in code.  You set this using the Procedure Attributes Screen.  

One of the most common uses of this type of thing is with the enabled property.  You can make a property on yoru control called Enabled, and put all the proper code you would like, but it will not function like expected.  This is because the enabled property is handled by the container object (the form you put the control on) and is a special type of property.  By setting the Procedure Attribute of your Enabled property to ENABLED, you tell VB to treat this like a normal enabled property.  You provide the code, but VB handles the messaging properly!

Hope this helps!
0
 

Author Comment

by:alanlam
ID: 1453912
Very close now. You didn't directly answer my question but the phrase that helped was "you tell VB to treat this like a normal enabled property"

After having yest another hard look at the differences between the two projects I noticed that under Advanced/Use this page in/Property - it was set to Data as opposed to (none) in my typed in version. Also
Advanced/Attributes/User Interface Default was ticked on the CD ROM version, but not on the one typed in. It didn't tell you to do any of this in the book Argggggghhhh.

Now DatabaseName properties under notepad has
Attribute DatabaseName.VB_ProcData.VB_Invoke_Property = ";Data"
Attribute DatabaseName.VB_MemberFlags = "200"

The first line is set by Advanced/Use this page in/Property/Data.
The second line is set by Advanced/Attributes/User Interface Default set to ticked.

Very, very close, but the typed in program still doesn't work.

So for the final part of my original question, how do I, from within VB5, get the first line to include "general" in it? Tell me step by step, even if it is obvious, because I think I'm going blind from looking at the same screens over and over again :-)

TIA
0
 

Author Comment

by:alanlam
ID: 1453913
Very close now. You didn't directly answer my question but the phrase that helped was "you tell VB to treat this like a normal enabled property"

After having yest another hard look at the differences between the two projects I noticed that under Advanced/Use this page in/Property - it was set to Data as opposed to (none) in my typed in version. Also
Advanced/Attributes/User Interface Default was ticked on the CD ROM version, but not on the one typed in. It didn't tell you to do any of this in the book Argggggghhhh.

Now DatabaseName properties under notepad has
Attribute DatabaseName.VB_ProcData.VB_Invoke_Property = ";Data"
Attribute DatabaseName.VB_MemberFlags = "200"

The first line is set by Advanced/Use this page in/Property/Data.
The second line is set by Advanced/Attributes/User Interface Default set to ticked.

Very, very close, but the typed in program still doesn't work.

So for the final part of my original question, how do I, from within VB5, get the first line to include "general" in it? Tell me step by step, even if it is obvious, because I think I'm going blind from looking at the same screens over and over again :-)

TIA
0
 

Author Comment

by:alanlam
ID: 1453914
Blast - forgot to hit reject answer. Could you answer the last comment please. Thanks
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

760 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