Odd behaviour - running program without clicking on code

RoryA

MrExcel MVP, Moderator
Joined
May 2, 2008
Messages
35,114
Office Version
365, 2019, 2016, 2010
Platform
Windows, MacOS
Something like this from the original code:

Code:
Property Get WordToGuess() As String

WordToGuess = pWordToGuess

End Property
 

Some videos you may like

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand

pjmorris

Well-known Member
Joined
Aug 2, 2012
Messages
1,903
Office Version
2016
Platform
Windows
Thanks Rory, I’ve not seen that construct before, so of to learn some more!!
 

tiredofit

Well-known Member
Joined
Apr 11, 2013
Messages
1,207
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?
 

RoryA

MrExcel MVP, Moderator
Joined
May 2, 2008
Messages
35,114
Office Version
365, 2019, 2016, 2010
Platform
Windows, MacOS
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)
 

tiredofit

Well-known Member
Joined
Apr 11, 2013
Messages
1,207
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?
 

RoryA

MrExcel MVP, Moderator
Joined
May 2, 2008
Messages
35,114
Office Version
365, 2019, 2016, 2010
Platform
Windows, MacOS
No, I haven't.
 

pjmorris

Well-known Member
Joined
Aug 2, 2012
Messages
1,903
Office Version
2016
Platform
Windows
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
 

tiredofit

Well-known Member
Joined
Apr 11, 2013
Messages
1,207
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"?
 

pjmorris

Well-known Member
Joined
Aug 2, 2012
Messages
1,903
Office Version
2016
Platform
Windows
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
 

RoryA

MrExcel MVP, Moderator
Joined
May 2, 2008
Messages
35,114
Office Version
365, 2019, 2016, 2010
Platform
Windows, MacOS
Yes. If you turn off the 'Auto data tips' setting, you shouldn't see the behaviour anymore.
 

Watch MrExcel Video

Forum statistics

Threads
1,102,117
Messages
5,484,842
Members
407,469
Latest member
moshea

This Week's Hot Topics

  • Finding issue in If elseif else with For each Loop
    Finding issue in If elseif else with For each Loop I have tried this below code but i'm getting in Y column filled with W005. Colud you please...
  • MsgBox Error
    Hi Guys, I have the below error show up when i try and run my macro in File1 but works fine if i copy and paste the same code into file2. [ATTACH...
  • CELL FORMAT - IF CONDITION
    My Cell Format is [B]""0.00" Cr". [/B]But in the cell, it is showing 123.00 for editing. (123 is entry figure). (Data imported from other...
  • Show numbers nearly the same
    Is this possible. I have a number that can change very time eg 0.00001234 Then I have a lot of numbers 0.0000001, 0.0000002, 0.00000004...
  • Please i need your help to create formula
    I need a formula in cell B8 to do this >>if b1=1 then multiply ( cell b8) by 10% ,if b1=2 multiply by 20%,if=3 multiply by 30%. Thank you in...
  • Got error while adding column and filter
    Got error while adding column and filter In column Z has some like "Success" and "Error". I want to add column in AA if the Z cell value is...
Top