 |
 |

06-04-2008, 01:00 PM
|
|
Junior Contributor
|
|
Join Date: Apr 2003
Location: San Diego, CA
Posts: 301
|
|
ComboBox Behavior
|
I am using a ComboBox [Style 0] to allow the user to select one of several choices. The specific choice becomes a parameter used by a procedure invoked by the ComboBox_Click event procedure.
At the end of the procedure, I want the Text property of the ComboBox restored to the default value set at Design time.
At the end of the procedure, I inserted the code:
Code:
ComboBox.Text = "Dist"
However, the ComboBox text property is set to a null string [blank] vice the desired.
I cannot understand why. My workaround has been to use the GotFocus event of the command button which is given focus at the end of the ComboBox click event procedure. This achieves the desired result but I cannot fathom why the simpler method does not work.
Any help is appreciated.
|
|

06-04-2008, 01:17 PM
|
 |
Senior Contributor
* Expert *
|
|
Join Date: May 2008
Posts: 1,012
|
|
|
Implement the _Change event, set a breakpoint on the .Text = "Dist" line and step through from there, that might give you a clue as to what is happening.
I'm using VBA and can't reproduce the problem, but if I do the above I see that the _Change event fires twice when changing the .Text in the _Click handler, as opposed to once when changing it in a different context, which might well be related to what you're seeing in VB proper.
|
__________________
"Lying in bed would be an altogether perfect and supreme experience if only one had a colored pencil long enough to draw on the ceiling."
Chesterton, "Tremendous Trifles"
|

06-04-2008, 02:35 PM
|
|
Junior Contributor
|
|
Join Date: Apr 2003
Location: San Diego, CA
Posts: 301
|
|
|
Following your suggestion, I created a ComboBox Change event procedure composed of simply a Stop statement so the program would stop on invocation of the ComboBox Change event.
When I did that, the workaround also failed.
Also, the only occurrence of the ComboBox Change Change event was when the program code set the ComboBox text property. The ComboBox Change event was NOT triggered when I selected an item from the combo box list. This apparently only triggers the ComboBox Click event.
I created a simple program to illustrate the annoyance I have ancountered.
|
Last edited by unclebill; 06-04-2008 at 03:03 PM.
Reason: Addition of attachment Demo Project
|

06-04-2008, 04:11 PM
|
 |
Senior Contributor
* Expert *
|
|
Join Date: May 2008
Posts: 1,012
|
|
Quote:
Originally Posted by unclebill
The ComboBox Change event was NOT triggered when I selected an item from the combo box list. This apparently only triggers the ComboBox Click event.
|
Yeah, that matches what it says in the MSDN:
Quote:
|
Occurs only if [...] the user changes the text or you change the Text property setting through code.
|
I had a nagging feeling that I had had some problem with the ComboBox_Click event before, and I remembered now: It's not possible to unload control array members in the handler, see here. I don't see any connection between the two oddities, other than their being odd, but figured it can't hurt to mention it.
I'm afraid I don't have anything more constructive to offer atm.
|
__________________
"Lying in bed would be an altogether perfect and supreme experience if only one had a colored pencil long enough to draw on the ceiling."
Chesterton, "Tremendous Trifles"
|

06-04-2008, 06:06 PM
|
 |
Multi-Technologist
Super Moderator * Expert *
|
|
Join Date: May 2004
Location: Michigan
Posts: 3,740
|
|
|
I have no problem getting it to work on Win2K after commenting out: 'cmdClose.SetFocus
Just a guess that you are not running VB6 SP6.
|
__________________
"May the code that you write never work in ways that you didn't expect; and may the code that you didn't write never require you to maintain it". - Ancient Chinese Proverb
|

06-04-2008, 07:26 PM
|
|
Junior Contributor
|
|
Join Date: Apr 2003
Location: San Diego, CA
Posts: 301
|
|
|
The only indication I see in the Help About response is Version 8176 VBA 6.0.8169 forms3: 11.0.5709. Does that tell you enough to kow what service pack I might have (if any)?
Thanks.
I got smart (well, sort of) and downloaded and installed SP6. It solved the problem.
Thanks.
|
Last edited by unclebill; 06-04-2008 at 07:44 PM.
Reason: Update status
|

06-04-2008, 10:02 PM
|
|
Junior Contributor
|
|
Join Date: Apr 2003
Location: San Diego, CA
Posts: 301
|
|
|
Wow! With SP6, my executable is much smaller. Before installing SP6 for VB6, I had a project that compiles to about 920K. After SP6, it compiles in about 1/3 the time and the .exe file is about 500K!
Is this typical in your experience? Thanks.
|
|

06-05-2008, 11:57 AM
|
 |
Multi-Technologist
Super Moderator * Expert *
|
|
Join Date: May 2004
Location: Michigan
Posts: 3,740
|
|
|
I can't recall comparing a base install against any service packs...but it is good to know that it is working well for you. There are lots of behavioral quirks cleaned up by SP6, as it contains all previous SP updates.
|
__________________
"May the code that you write never work in ways that you didn't expect; and may the code that you didn't write never require you to maintain it". - Ancient Chinese Proverb
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|
|
|
|
 |
|