Visual Basic 2005 Cookbook: Solutions for VB 2005 Programmers (Cookbooks (OReilly))
Problem
You want to double-space a string comprised of multiple lines of text separated by newlines. Solution
Use the String object's Replace() method to replace all vbNewLines with two vbNewLines. Discussion
The Replace() method provides an easy solution to this problem. Simply replace each occurrence of a vbNewLine separating the lines of text with a double vbNewLine: content = content.Replace(vbNewLine, vbNewLine & vbNewLine) Figures 5-20 and 5-21 show a multiline example string before and after this replacement. Figure 5-20. A string comprised of five lines of single-spaced text Figure 5-21. The same string, double spaced See Also
Recipe 5.16 shows how to replace specific substrings within a larger string. |
Категории