Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it good practice to leave "Debug.Print" instructions in code that goes in "production"?

Tags:

excel

vba

In Excel VBA, is it good practice to leave Debug.Print instructions in code that goes in "production" ? That is quite useful to debug the sheets realtime at the user's machine when something goes wrong. Does it affect performance when Visual Studio is closed ? If not, what would you advise ?

like image 853
BuZz Avatar asked Dec 07 '11 08:12

BuZz


1 Answers

Debug.Print instruction DO have a small performance cost. So I would avoid them in loops that are executed a zillion times. Except for those cases, I think it's ok to keep them.
You could also use conditional compilation directives (#if) in combination with a compiler constant (#const) to enable/disable them globally without performance impact.

#CONST developMode = True

sub Xyz
  #If developMode Then
    Debug.Print "something"
  #End If
End Sub
like image 177
iDevlop Avatar answered Nov 15 '22 19:11

iDevlop