Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > Pro VB 6
|
Pro VB 6 For advanced Visual Basic coders working in version 6 (not .NET). Beginning-level questions will be redirected to other forums, including Beginning VB 6.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro VB 6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 27th, 2003, 06:30 AM
Authorized User
 
Join Date: Nov 2003
Posts: 47
Thanks: 0
Thanked 0 Times in 0 Posts
Default Unbelievable !! (at least for me...)

Hi

I have a form with 2 ARRAYS : command1 and label1 and some code, which says :

...
label1(ind).visible = command1(ind).visible
....

[with ind = some index].

Despite the fact that some command1(ind) become visible (I explicitly set them in code), label1(ind) NEVER becomes visible, because when sampled, command1(ind).visible ALWAYS returns the value it was set at Design Time.

After lots of banging my head against various objects, I finally tried this (to make sure it happens):

...
command1(ind).visible = true
if command1(ind).visible then <some code>
...

Guess what ? The <some code> never executes !! Also, when using the Watch Window, the .Visible property of command1(ind) never changes - it stays the way I set it at Design Time ! (although it becomes visible on the form !)

Is this Christmas or Halloween ?

Have some clue ?



 
Old December 29th, 2003, 11:46 AM
Ned Ned is offline
Authorized User
 
Join Date: Jun 2003
Posts: 66
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I had a problem like that; looks like its a VB bug. But when I created an EXE of the same code; guess what? it amazingly worked. So I will ask you, try to run with full compile (Ctrl+F5), if that does not work then you can go for EXE.

-Ned
 
Old December 30th, 2003, 02:34 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 627
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Be careful not to test the Visible property in the Load event, because normally it is valid only after that the form has been loaded.
What I usually do is using the Activate or Paint event, with a static boolean flag so I can run the code only once. When I really has to use the Load event (because of code legacy) I use the components' Tag property if not already used, otherwise a local boolean array.

Marco









Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.