Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 477
Default Duplicating of Message Boxes

The below shows the 2 MB's Twice -- OK the first time, but I ned to
eliminate them from ccurring the 2nd time (text only shows - no values)
Thanks,

Private Sub ComboBox1_Change()
Application.EnableEvents = False
MsgBox "You have chosen " & ComboBox1.Value
MsgBox "The next step in this macro will deselect it"
Me.ComboBox1.ListIndex = -1
Application.EnableEvents = True
End Sub
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Duplicating of Message Boxes

..enableevents will stop worksheet events, workbook events, application events
from firing. Not events for these controls.

But you can mimic it:

Dim BlkProc as boolean
Private Sub ComboBox1_Change()
if blkproc = true then exit sub

MsgBox "You have chosen " & ComboBox1.Value
MsgBox "The next step in this macro will deselect it"

blkproc = true
Me.ComboBox1.ListIndex = -1
blkproc = false

End Sub

Jim May wrote:

The below shows the 2 MB's Twice -- OK the first time, but I ned to
eliminate them from ccurring the 2nd time (text only shows - no values)
Thanks,

Private Sub ComboBox1_Change()
Application.EnableEvents = False
MsgBox "You have chosen " & ComboBox1.Value
MsgBox "The next step in this macro will deselect it"
Me.ComboBox1.ListIndex = -1
Application.EnableEvents = True
End Sub


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 477
Default Duplicating of Message Boxes

Thanks Dave. Can you reinterate a bit on what the code is doing here?
I can follow it some, but not all-the-way.
Thanks,
Jim

"Dave Peterson" wrote:

..enableevents will stop worksheet events, workbook events, application events
from firing. Not events for these controls.

But you can mimic it:

Dim BlkProc as boolean
Private Sub ComboBox1_Change()
if blkproc = true then exit sub

MsgBox "You have chosen " & ComboBox1.Value
MsgBox "The next step in this macro will deselect it"

blkproc = true
Me.ComboBox1.ListIndex = -1
blkproc = false

End Sub

Jim May wrote:

The below shows the 2 MB's Twice -- OK the first time, but I ned to
eliminate them from ccurring the 2nd time (text only shows - no values)
Thanks,

Private Sub ComboBox1_Change()
Application.EnableEvents = False
MsgBox "You have chosen " & ComboBox1.Value
MsgBox "The next step in this macro will deselect it"
Me.ComboBox1.ListIndex = -1
Application.EnableEvents = True
End Sub


--

Dave Peterson

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Duplicating of Message Boxes

The code just sets a toggle. You turn it on right before you change something
that would cause the _change procedure to fire.

It doesn't stop the event from firing a second time, but that first line says
that if the toggle is on, don't do any of the real code--just get the heck out.

And after you make the change, you turn that toggle off.

Step through it and you'll see that it really does fire twice.

Jim May wrote:

Thanks Dave. Can you reinterate a bit on what the code is doing here?
I can follow it some, but not all-the-way.
Thanks,
Jim

"Dave Peterson" wrote:

..enableevents will stop worksheet events, workbook events, application events
from firing. Not events for these controls.

But you can mimic it:

Dim BlkProc as boolean
Private Sub ComboBox1_Change()
if blkproc = true then exit sub

MsgBox "You have chosen " & ComboBox1.Value
MsgBox "The next step in this macro will deselect it"

blkproc = true
Me.ComboBox1.ListIndex = -1
blkproc = false

End Sub

Jim May wrote:

The below shows the 2 MB's Twice -- OK the first time, but I ned to
eliminate them from ccurring the 2nd time (text only shows - no values)
Thanks,

Private Sub ComboBox1_Change()
Application.EnableEvents = False
MsgBox "You have chosen " & ComboBox1.Value
MsgBox "The next step in this macro will deselect it"
Me.ComboBox1.ListIndex = -1
Application.EnableEvents = True
End Sub


--

Dave Peterson


--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 477
Default Duplicating of Message Boxes

Pretty Cool, it's amazing what all you have to consider in doing something
like this.
Thanks, Dave I (much) better understand - by stepping through the code.

"Dave Peterson" wrote:

The code just sets a toggle. You turn it on right before you change something
that would cause the _change procedure to fire.

It doesn't stop the event from firing a second time, but that first line says
that if the toggle is on, don't do any of the real code--just get the heck out.

And after you make the change, you turn that toggle off.

Step through it and you'll see that it really does fire twice.

Jim May wrote:

Thanks Dave. Can you reinterate a bit on what the code is doing here?
I can follow it some, but not all-the-way.
Thanks,
Jim

"Dave Peterson" wrote:

..enableevents will stop worksheet events, workbook events, application events
from firing. Not events for these controls.

But you can mimic it:

Dim BlkProc as boolean
Private Sub ComboBox1_Change()
if blkproc = true then exit sub

MsgBox "You have chosen " & ComboBox1.Value
MsgBox "The next step in this macro will deselect it"

blkproc = true
Me.ComboBox1.ListIndex = -1
blkproc = false

End Sub

Jim May wrote:

The below shows the 2 MB's Twice -- OK the first time, but I ned to
eliminate them from ccurring the 2nd time (text only shows - no values)
Thanks,

Private Sub ComboBox1_Change()
Application.EnableEvents = False
MsgBox "You have chosen " & ComboBox1.Value
MsgBox "The next step in this macro will deselect it"
Me.ComboBox1.ListIndex = -1
Application.EnableEvents = True
End Sub

--

Dave Peterson


--

Dave Peterson



  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Duplicating of Message Boxes

You can observe a lot just by watching!

<vbg

Jim May wrote:

Pretty Cool, it's amazing what all you have to consider in doing something
like this.
Thanks, Dave I (much) better understand - by stepping through the code.

"Dave Peterson" wrote:

The code just sets a toggle. You turn it on right before you change something
that would cause the _change procedure to fire.

It doesn't stop the event from firing a second time, but that first line says
that if the toggle is on, don't do any of the real code--just get the heck out.

And after you make the change, you turn that toggle off.

Step through it and you'll see that it really does fire twice.

Jim May wrote:

Thanks Dave. Can you reinterate a bit on what the code is doing here?
I can follow it some, but not all-the-way.
Thanks,
Jim

"Dave Peterson" wrote:

..enableevents will stop worksheet events, workbook events, application events
from firing. Not events for these controls.

But you can mimic it:

Dim BlkProc as boolean
Private Sub ComboBox1_Change()
if blkproc = true then exit sub

MsgBox "You have chosen " & ComboBox1.Value
MsgBox "The next step in this macro will deselect it"

blkproc = true
Me.ComboBox1.ListIndex = -1
blkproc = false

End Sub

Jim May wrote:

The below shows the 2 MB's Twice -- OK the first time, but I ned to
eliminate them from ccurring the 2nd time (text only shows - no values)
Thanks,

Private Sub ComboBox1_Change()
Application.EnableEvents = False
MsgBox "You have chosen " & ComboBox1.Value
MsgBox "The next step in this macro will deselect it"
Me.ComboBox1.ListIndex = -1
Application.EnableEvents = True
End Sub

--

Dave Peterson


--

Dave Peterson


--

Dave Peterson
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Error message boxes.... Dermot Excel Discussion (Misc queries) 14 April 28th 06 03:41 PM
Message boxes JaB Excel Discussion (Misc queries) 1 November 10th 05 12:02 PM
Built in message boxes bgeldart Excel Discussion (Misc queries) 1 March 14th 05 02:27 PM
Built in message boxes Ben Geldart Excel Discussion (Misc queries) 0 March 14th 05 12:27 PM
Hiding message boxes DianeD Excel Discussion (Misc queries) 0 March 12th 05 12:01 AM


All times are GMT +1. The time now is 04:17 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"