怎样崽字符串中加入enter等特殊的字符呢??(1分)

  • 主题发起人 主题发起人 ajim
  • 开始时间 开始时间
A

ajim

Unregistered / Unconfirmed
GUEST, unregistred user!
怎样崽字符串中加入enter等特殊的字符呢??
 
#13 就是换行
 
Object Pascal Language Guide
Character strings

Topic groups See also

A character string, also called a string literal or string constant, consists of a quoted string, a control string, or a combination of quoted and control strings. Separators can occur only within quoted strings.
A quoted string is a sequence of up to 255 characters from the extended ASCII character set, written on one line and enclosed by apostrophes. A quoted string with nothing between the apostrophes is a null string. Two sequential apostrophes in a quoted string denote a single character, namely an apostrophe. For example,

'BORLAND' { BORLAND }

'You''ll see' { You'll see }
'''' { ' }
'' { null string }
' ' { a space }

A control string is a sequence of one or more control characters, each of which consists of the # symbol followed by an unsigned integer constant from 0 to 255 (decimal or hexadecimal) and denotes the corresponding ASCII character. The control string

#89#111#117

is equivalent to the quoted string

'You'

You can combine quoted strings with control strings to form larger character strings. For example, you could use

'Line 1'#13#10'Line 2'

to put a carriage-return–line-feed between “Line 1” and “Line 2”. However, you cannot concatenate two quoted strings in this way, since a pair of sequential apostrophes is interpreted as a single character. (To concatenate quoted strings, use the + operator or simply combine them into a single quoted string.)
A character string’s length is the number of characters in the string. A character string of any length is compatible with any string type and with the PChar type. A character string of length 1 is compatible with any character type, and, when extended syntax is enabled ({$X+}), a nonempty character string of length n is compatible with zero-based arrays and packed arrays of n characters. For more information about string types, see String types.
 
你可以看看delphi帮助
 
比如原有字符串:s := 'abcdefg';
加入在第三个字符后面插入换行:
Insert(#13#10, s, 3);
其中 #13#10 即回车换行
 
'asdf'+chr(13)+'asdfasdf'
 
'abcdefg'#13#10'uvwxyz'
#13#10要一起
 
//#13#10要一起
是的,记住
不过要是该字符串你是用在 ShowMessage 或 MessageBox 或 TLabel 等中,可以省略 #10
但是在 TMemo, TRichEdit 等重则必须两个都带上,所以,建议最好是一起带上,准没错
 
接受答案了.
 

Similar threads

回复
0
查看
885
不得闲
D
回复
0
查看
848
DelphiTeacher的专栏
D
D
回复
0
查看
858
DelphiTeacher的专栏
D
后退
顶部