I am trying my first user control, but after I save it as an .ocx and try to add it to my project, it tells me the control can not be used as a public and is changing it to private.
Can anyone explain this to me?
It is a really simple text box that takes the entry and sets the tag property to the text(modified) in the box.
Start a new EXE project. Then add the control. You will be able to use it from the Form or whatever. VB will change it from Public to Private because of the type of project.
The only time you will have a Public control is if you are making a project of type OCX.
Nobody knows what software they want until after you've delivered what they originally asked for.
Don't solve problems which don't exist.
"If I had eight hours to cut down a tree, I'd spend six hours sharpening my axe." --- Abraham Lincoln (1809-1865)
Well if you make a project of type OCX then VB expects you will have at least 1 .ctl file in the project. When you compile the object, and then make it binary compatible, other applications can ask the COM engine to deliver a running instance to its process space.
For all that to work, it needs to be public.
The consuming application can be of type Standard EXE. In this case, it can either add it as a binary component, or as a source code component. If you load the .CTL in the project as source code, the IDE makes it Private because it is not going to advertise its availability from an EXE project.
That would only happen from an OCX type project.
Nobody knows what software they want until after you've delivered what they originally asked for.
Don't solve problems which don't exist.
"If I had eight hours to cut down a tree, I'd spend six hours sharpening my axe." --- Abraham Lincoln (1809-1865)
When I start a new project, add this control (as private), and add the following code...I get a blank message box?
VB Code:
Private Sub ucMyBox1_LostFocus()
MsgBox (ucMyBox1.Tag), vbInformation
End Sub
Thanks for you help.
Yes, the .Tag will be blank. I don't know if you can access that Property from within the .CTL code. You are better off exposing your own custom Public Property. I did the same thing when making a PLC OCX wrapper. Instead of my consumer accessing the .Tag property, I made a .TagName Property which my consumer could write to, and I could read from.
Nobody knows what software they want until after you've delivered what they originally asked for.
Don't solve problems which don't exist.
"If I had eight hours to cut down a tree, I'd spend six hours sharpening my axe." --- Abraham Lincoln (1809-1865)