VB6 control cant set visible property at runtime

Hi

I have a usercontrol which I would like to run the following code on but although if I click on an instance on the form I am able to set the visible property I dont seem to be able to at runtime.  if I do me. then visible isnt one of the options.  ASONText is a property created and put into the propertybag.

      
If Left(Me.ASOnText, 9) = "Condition" Then
    Me.Visible = False
else
   Me.Visible = True
End If

Open in new window

LVL 1
simonwaitAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

HooKooDooKuCommented:
Assuming a 'Visible' property exists for the usercontrol, it might have been declared as 'Private'.  If so, they you can not access the property using 'Me'.  Simply access the property directly.
If Left(Me.AsOnText, 9) = "Condition" Then
    Visible = False
Else
    Visible = True
End If

Open in new window

0
Martin LissOlder than dirtCommented:
Are you trying to make the usercontrol visible or are you trying to make the form visible?
0
simonwaitAuthor Commented:
Im trying to control the usercontrol visibility.  I assume that although I can set this if I click on the usercontrol and select from the options in the properties window that it does exist.  However if im wrong is there a way for me to create it?
0
Martin LissOlder than dirtCommented:
You might take a look at my NumberBox ActiveX control to see if it's of any help.

It's been a while since I wrote a user control so I don't know if this would help but do you have the Visible property in the property bag?
0
HooKooDooKuCommented:
First of all, I just figured out that when you are working with a UserControl, you don't use 'Me' to get to properties of the control, you use 'UserControl'.

But I still can't find any sort of  'Visible' property under 'UserControl'.

But here is what you can do.

At the Top of your UserControl code, add the following lines:
Private Declare Function ShowWindow Lib "user32.dll" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
Private Const SW_HIDE = 0
Private Const SW_SHOW = 5

Open in new window

Then in your User Control code, use the following line of code to hide the window.
Call ShowWindow(UserControl.hwnd, SW_HIDE)

Open in new window

However, note that the call to ShowWindow will fail if the control doesn't exist yet.  So if you called this function in the 'UserControl_Initialize' event, the hwnd will have a value of NULL and the window will not be hidden.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.