Most debugging features illustrated in this chapter require some code before you can use them. At the moment, it’s more important that you understand the Visual Studio 2015 instrumentation than see complex code, so we start with a simple code example that is a good base for understanding how the debugger works. You can create a new Visual Basic project for the Console and then type the code, as shown in Listing 5.1.
Module Module1
Sub Main()
Console.WriteLine("Enter a valid string:")
Dim lineRead As String = Console.ReadLine()
Dim result As Boolean = Test(lineRead)
Console.WriteLine("Is a valid string: " & result.ToString)
Console.ReadLine()
End Sub
Function Test(name As String) As Boolean
If String.IsNullOrEmpty(name) = False Then
Return True
Else
Return False
End If
End Function
End Module
The code is quite simple. The application just asks the user to enter a string and then returns False
if the string is null or is empty; it returns True
if the string is valid. With such simple code, you can now begin learning the advanced debugging instrumentation available in Visual Studio 2015.
18.221.117.214