Odd behaviour - running program without clicking on code

tiredofit

Well-known Member
Joined
Apr 11, 2013
Messages
1,825
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
I have recently come across a program whereby if I merely hover the mouse over a particular line of code, the program runs.

Has anyone come across such odd behaviour?
 
Something like this from the original code:

Code:
Property Get WordToGuess() As String

WordToGuess = pWordToGuess

End Property
 
Upvote 0

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
Thanks Rory, I’ve not seen that construct before, so of to learn some more!!
 
Upvote 0
If you hover over that, the IDE has to run the code for that property to show you the value. It will not simply show you the value returned previously.

When you hover the mouse over the word Letter in this line:

Code:
If Not Letter.IfTooManyGoes Then

the code runs and a message pops up, inviting the user to "Think of a letter".

You can guess a letter or click Cancel, in which case the program goes about it usual way. It doesn't stop.

So are you saying it's all perfectly normal?
 
Upvote 0
Since IfTooManyGoes is a property, the code for that property has to be run to show you the value (assuming you have the default 'Auto data tips' setting checked). It shouldn't run anything that is not part of, or called by, that property code. However, using MsgBox or Inputbox statements can cause a focus shift which works as if you hovered over the property again (and again, and again)
 
Upvote 0
That's what I found strange.

The message box popped up and continued running normally.

Have you tried copying the code into a new workbook and see it happen?
 
Upvote 0
I've now copied it and tested it - its new behaviour to me and I can see exactly what Rory is talking about. When you hover over the 'IfTooManyGoes value is hovered over, the editor needs to run code to obtain the value. It therefore executes the code below within which is a call to StartGuess and so the whole process starts again. When a LetterGuessed is returned then I'd expect you to be returned to the break point and the editor will show you the new value. (Not completely sure thats true, but from my current learning thats what I'd expect).

Rich (BB code):
Public Property Get IfTooManyGoes() As Boolean
  
If LetterGuessed = "" Then StartGuess

IfTooManyGoes = (LetterGuessed <> "")

End Property

HTH
 
Upvote 0
I've now copied it and tested it - its new behaviour to me and I can see exactly what Rory is talking about. When you hover over the 'IfTooManyGoes value is hovered over, the editor needs to run code to obtain the value. It therefore executes the code below within which is a call to StartGuess and so the whole process starts again. When a LetterGuessed is returned then I'd expect you to be returned to the break point and the editor will show you the new value. (Not completely sure thats true, but from my current learning thats what I'd expect).

Rich (BB code):
Public Property Get IfTooManyGoes() As Boolean
 
If LetterGuessed = "" Then StartGuess

IfTooManyGoes = (LetterGuessed <> "")

End Property

HTH

I was about to upoload the file for all to test but I assume you're now saying, (thanks to Rory's clarification), that the program's behaviour is "as expected"?
 
Upvote 0
simple answer, Yes. I hadn't come across this behaviour before and it would have surprised me too. Guess thats why we have MVPs contributing - thank you Rory. Within the company I know more than most about excel, but here I'm forever discovering that even that is small to what there is to know
 
Upvote 0
Yes. If you turn off the 'Auto data tips' setting, you shouldn't see the behaviour anymore.
 
Upvote 0

Forum statistics

Threads
1,213,546
Messages
6,114,251
Members
448,556
Latest member
peterhess2002

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top