Find Trouble Spots

Find Trouble Spots

Implement a low-tech trace of your application by writing a message whenever your code enters and exits a subroutine. This can help you locate elusive bugs, because you can turn on the trace and run your application until failure. The last entry in your log indicates what subroutine you were executing when the failure occurred. Enter this code in the General Declarations section of a module:

 Public DebugMode as Boolean

Normally, you should set this variable to False. During debugging, however, set it to True (DebugMode = True). Place this sub in the module:

 Public Sub WriteDebugMessage(ByVal Msg as String)	If DebugMode then		'write a message, including the system time		End If	End Sub

Enter this code as the first statement in every subroutine and function in your project:

 Call WriteDebugMessage("Entering NameOfSubroutine")

Enter this code as the last statement in every subroutine and function:

 Call WriteDebugMessage("Exiting NameOfSubroutine")

VB4 introduced conditional compilation, which offers a simpler way to implement this scheme. By defining a conditional compiler constant rather than a global flag variable, you can optimize your final EXE by toggling the constant to False. Conditional calls to the WriteDebugMessage routine won’t be compiled into your shipping build:

 #Const DebugMode = False' for final code, true to test#If DebugMode Then	Call WriteDebugMessage("Important Info")#End If

Use this code to write other debug information to the log, such as variable values. Don’t forget to turn off Debug mode when you’re not using it to avoid writing massive amounts of unneeded data to the log.

Share the Post:
Heading photo, Metadata.

What is Metadata?

What is metadata? Well, It’s an odd concept to wrap your head around. Metadata is essentially the secondary layer of data that tracks details about the “regular” data. The regular

XDR solutions

The Benefits of Using XDR Solutions

Cybercriminals constantly adapt their strategies, developing newer, more powerful, and intelligent ways to attack your network. Since security professionals must innovate as well, more conventional endpoint detection solutions have evolved

AI is revolutionizing fraud detection

How AI is Revolutionizing Fraud Detection

Artificial intelligence – commonly known as AI – means a form of technology with multiple uses. As a result, it has become extremely valuable to a number of businesses across

AI innovation

Companies Leading AI Innovation in 2023

Artificial intelligence (AI) has been transforming industries and revolutionizing business operations. AI’s potential to enhance efficiency and productivity has become crucial to many businesses. As we move into 2023, several