Re: To clear a listbox
From: Stan Hilliard (usenetreplyMS_at_samplingplansNOTSPAM.com)
Date: 08/13/04
- Next message: Randy Birch: "Re: To clear a listbox"
- Previous message: Randy Birch: "Re: To clear a listbox"
- In reply to: Randy Birch: "Re: To clear a listbox"
- Next in thread: Randy Birch: "Re: To clear a listbox"
- Reply: Randy Birch: "Re: To clear a listbox"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 12 Aug 2004 22:42:02 -0500
On Thu, 12 Aug 2004 21:41:32 -0400, "Randy Birch"
<rgb_removethis@mvps.org> wrote:
>Strange.
>
>As for why the option event executed ... Option1 will fire if you're setting
>its value property during the load. This includes setting it to False. Add a
>boolean flag to the form general declaration -- eg bSkipIt as boolean -- and
>as the first line in the option button routine put:
>
>if bSkipIt then exit sub
>
>... then in the load event set bSkipIt = True before the code firing the
>option value change, and = False before the Load ends.
I have no code in my Form_Load to fire the option button. But it fired
automatically following the exit from Form_Load. Prior to loading, the
lone option button' original value = false.
I determined that if there is only one option button and its original
value = false, it will change to True and execute Option1_Click --
after Form_Load finishes executing.
If there is only one option button and its original value = True, it
will not fire after Form_Load executes.
If there are multiple option buttons and all are originally False, one
of the buttons will change to True and its OptionX_Click will execute
-- after Form_Load finishes executing, The button changed is the one
with lowest value of Tabindex.
If there are multiple option buttons and one button is originally
True, none of the buttons will fire after Form_Load executes.
In general, after loading, VB6 enforces that with one or more option
buttons, one must be True.
Stan Hilliard
>: On Thu, 12 Aug 2004 13:37:58 -0400, "Randy Birch"
>: <rgb_removethis@mvps.org> wrote:
>:
>: >Those are the correct 4 and the correct order ... I was thinking
>something
>: >may have loaded that also had a clear method that VB was getting confused
>: >about. Does VB abort if you place this same code in a brand new app (File
>/
>: >New > Standard EXE) ?
>: >
>: >Option Explicit
>: >
>: >Private Sub Form_Load()
>: >
>: > Dim cnt As Long
>: > For cnt = 1 To 12
>: > lstReports.AddItem String(cnt, "B")
>: > Next
>: >
>: >End Sub
>: >
>: >Private Sub Option1_Click()
>: >
>: > lstReports.Clear
>: >
>: >End Sub
>:
>: I added the code to Form1 of a new project, with a listbox named
>: lstReports and one option button named Option1.
>:
>: The "lstReports.Clear" cleared the Listbox.
>:
>: Stepping with F8, the new project loads a listbox with 12 items and
>: then shows it following the "End Sub" of "Form_Load". However, after
>: that "End Sub" the project continues to step through option1_click().
>:
>: Apparently, the Option1_Click() fires during the loading process.
>: That was a surprise to me. Is that the way that the load is supposed
>: to work?
>:
>: I went back and ran yesterday's test project that failed. The
>: "lstReports.Clear" statement does not fail today -- even though it
>: failed multiple times in different projects yesterday.
>:
>: Here is one project that was failing yesterday:
>:
>: Option Explicit
>:
>: Private Sub Command1_Click()
>: List1.AddItem "Item"
>: End Sub
>:
>: Private Sub Option1_Click()
>: List1.Clear
>: End Sub
>:
>:
>: Perhaps rebooting the computer made the difference.
>:
>: 'Stan Hilliard
>:
>: >"Stan Hilliard" <usenetreplyMS@samplingplansNOTSPAM.com> wrote in message
>: >news:j0tlh0t7ms1i4c73cpphq47a0oms030gog@4ax.com...
>: >: On Wed, 11 Aug 2004 23:37:40 -0400, "Randy Birch"
>: >: <rgb_removethis@mvps.org> wrote:
>: >:
>: >: >In the project that crashes, under project/references what are the
>first
>: >: >four items checked, in order?
>: >: >Randy Birch
>: >:
>: >: 1) Visual Basic For Applications
>: >: 2) Visual Basic runtime objects and procedures
>: >: 3) Visual Basic objects and procedures
>: >: 4) OLE Automation
>: >:
>: >: Stan Hilliard
>: >:
>: >: >"Stan Hilliard" <usenetreplyMS@samplingplansNOTSPAM.com> wrote in
>message
>: >: >news:c8plh0pg0k248c1dll6p6e36kelrqamp21@4ax.com...
>: >: >: On Wed, 11 Aug 2004 20:20:12 -0400, "Jeff Johnson"
><i.get@enough.spam>
>: >: >: wrote:
>: >: >:
>: >: >: >
>: >: >: >"Stan Hilliard" <usenetreplyMS@samplingplansNOTSPAM.com> wrote in
>: >message
>: >: >: >news:r84lh05249svvrcvl5je2c426mgcedfki2@4ax.com...
>: >: >: >
>: >: >: >> And this doesn't work:
>: >: >: >>
>: >: >: >> lstReports.Clear
>: >: >: >>
>: >: >: >> The latter causes the VB6 environment to abort, even though there
>is
>: >: >: >> an error trap.
>: >: >: >
>: >: >: >If the IDE is crashing on this line, there's a problem with your
>: >: >: >installation. This is valid syntax and works just fine for me.
>: >: >: >
>: >: >:
>: >: >: I have three forms in the project that have listboxes - all named
>: >: >: lstReports.
>: >: >:
>: >: >: I tested a second listbox with "lstReports.Clear" and that brought
>: >: >: down the IDE also.
>: >: >:
>: >: >: I then create a new project and tested List1.Clear with all new
>code.
>: >: >: That brought down the IDE also.
>: >: >:
>: >: >: I agree that the problem is with my installation. Should I
>: >: >: uninstall/reinstall or does VB have a method to just refresh what is
>: >: >: there?
>: >: >:
>: >: >: I have VB6 SP5. The date of VB6.exe is 9/15/00 12:00 AM, size =
>: >: >: 1,840KB. Is there an upgrade that I should install at the same time?
>: >: >:
>: >: >: Or, is it better to just replace VB.OLB.
>: >: >:
>: >: >: Stan Hilliard
>: >:
>:
- Next message: Randy Birch: "Re: To clear a listbox"
- Previous message: Randy Birch: "Re: To clear a listbox"
- In reply to: Randy Birch: "Re: To clear a listbox"
- Next in thread: Randy Birch: "Re: To clear a listbox"
- Reply: Randy Birch: "Re: To clear a listbox"
- Messages sorted by: [ date ] [ thread ]