Inspecting the End of a Long Variable Value in VBA

You probably know that you can hover over a variable while VBA is in break mode to inspect its contents.  The value of the variable will appear in a tooltip below the variable.

I'll use the following code in my samples below:

Sub TestVariableInspection()
    Dim s As String
    s = "Short string"
    Stop
    
    Dim x As String
    x = "12345678 1" & _
        "12345678 2" & _
        "12345678 3" & _
        "12345678 4" & _
        "12345678 5" & _
        "12345678 6" & _
        "12345678 7" & _
        "12345678 8" & _
        "12345678 9" & _
        "12345678 0"
    Stop
End Sub

The Simple Case: A Short String

If I run this routine to the first Stop statement, the length of the string in variable s is small enough that its entire contents are displayed:

Long String: Right Side of Value is Truncated

With a long string, the right side of the value is truncated.  VBA displays an ellipsis (...) to indicate there are additional characters.  In the screenshot below, only the first 71 characters are displayed.  

[Ctrl] + {Hover}: Left Side of Value is Truncated

Sometimes, the important part of the variable is what appears on the right-side of the value.  This is often the case, for example, when dealing with full file paths.  Generally, you will be more interested in the file name than the drive letter and root folders.

To view the right side of a long variable value, hold down the [Ctrl] key before hovering over the variable with the mouse pointer:

In this screenshot, only the last 70 characters are displayed in the tooltip.

On a side note, the difference in how many characters are displayed (71 vs. 70) makes me think that the restriction is based on the width of the tool tip rather than the number of characters in the value.

Image by 165106 from Pixabay