Sometimes your computer may display a message stating that debug.print vba is being formatted. There can be several reasons for this problem.



Debug.Print examples have been pretty good so farsimple – Debug.Print followed by a message – but – a statementThe message format can be slightly more complex than plain text.

On the one hand, the position at which the message appears in the direct windowit is possible through the text of the last message using VBs or. you can specifyspc () Tab () functions. If you want to indentmessage with ten spaces, there are two ways to do this:

Tab Debug.Print (11) “This message starts at column 12, which is functional.identical. “

Of course Spc () adds buildings to the output andTab () creates the position at which the next message should appear.

format debug.print vba

It is also possible to use multiple text reflections on one line:

Dim sDebugMsg for data strings
sDebugMsg = “self-destruct in five seconds, master
Phelps. “
Debug.Print “This message” & sDebugMsg

When you need to combine different text expressions for use with the latest standalone debug.Declaration, print syntax is a bit overloaded. Text after each printYou can see where to place VB next
Expression. Are there three ways to accomplish this?

You can first place a large semicolon after the text expression. This includes gluingPoint directly to the character following the last character that appeared.

This means that for the start character of the next print, the idea is printed immediately.after the last character of the expression before the semicolon. For an almost completeThis behavior results in a semicolon as well as “&”Channel owner. In fact, the last line related to the previous example might bewere written like this:

Second, you can include the Tab () function in the techniqueFocus on a specific smile. If you need a gap between messages,You canTry something like this (if you have a useful and unusually large screen):

Debug.Print “This is a small but effective step for humans”; Tab (100); “;
big leap for VB “

What if the client specifies a tab stop that will necessarily trigger a portion of the ending?Should the text expression be overwritten? Previous text expression ahead example. consists of 29 characters, for example. What if you did it?

Debug entry. “Having a man is a small step”; Tab (11); “;
a powerful jump to the next most important line for VB “

We can assume that the output in the Quick Launch will look like this:a; bulk jump to the next line for VB “starting from the second text namein column 11 of the same row. The point is, in VB, you save someone from such mistakes by going tothe second expression in column 11 is appended to the next row.

Finally, you can use Tab with no arguments (remember to omit the parentheses, otherwisesame; VB generates a syntax error) and sets the insertion pointoften at the beginning of the next level nprint. (On average, the pressure in the zone appears approx.14 columns.)

Remember that many semicolons and tabs are aesthetic. If you don’tSpecify where you will then place the character, it will be permanently printed on the next line. Youthese formatting rules can be used to get the output in a variety of ways.However, this example should give you an idea of ​​how to combine them. Figure 18.15 seriesresult:

Private subordinate function cmdOK_Click ()
Dim sRef as string, sMsg1 as string, sMsg2 as string
sRef “12345678901234567890123456789012345678901234567890”
SMsg1 = = “I am a real string of exactly 40 characters”
sMsg2 means “followed by optional command text 46”.
Debug.Print sRef
Debug.Print sMsg1; CPS (5); sMsg2
Debug.Print sMsg1; Tab (46); sMsg2
Debug.Print sMsg1; Tab (Len (sMsg1) + 6); sMsg2; vbCr
Debug.Print “End!”
End subscription

FIGURE 18.15 An example of formatting the Debug.Print output looks like this.

Note, among other things, how legal it is to use function calls and the Debug.Print line. Lens()The function determines how long sMsg1 takeschno is a, and then add six more columns to show the usually output. duplicateother lines. Why is there a line right before “The End!” “? So to speakbecause according to vbCr there is no orientation specifierconstant (yes, there are usually built-in constants as well). you do not haveIndicate where to put Mother Nature itself next to it so that it will be printed on the next line.vbCr.

format debug.print vba

NOTE. VB supports sequential textual Debug.Print expressions:If you are trying to align the footprints with Debug.Text,VB inserts a suitable semicolon between them. In other words, if you type:

After families hit Enter to move to the next line, VB changes easily.Your debug message about this: