Text.StrLen(Text) Method
Version: Available or changed with runtime version 1.0.
Gets the length of a string you define.
Syntax
Length := Text.StrLen(String: Text)
Note
This method can be invoked without specifying the data type name.
Parameters
String
Type: Text
The string for which you want to determine the length.
Return Value
Length
Type: Integer
The length of the string.
Remarks
The difference between the StrLen method and the MaxStrLen Method (Code, Text) is that the StrLen returns the actual number of characters in the input string, whereas MaxStrLen returns the maximum defined length of the input string.
In Dynamics 365 Business Central, if you call StrLen on a Variant, then you get an error that the contents of the parameter are not valid. In earlier versions of Dynamics 365, if you call StrLen on a Variant, then 0 is returned.
Example
This example shows the difference between the StrLen and the MaxStrLen methods.
var
City: Text[30];
MaxLength: Integer;
Length: Integer;
Text000: Label 'Atlanta';
Text001: Label 'The MaxStrLen method returns: %1,\\';
Text002: Label 'whereas the StrLen method returns: %2';
begin
City := Text000;
MaxLength := MaxStrLen(City);
Length := StrLen(City);
Message(Text001 + Text002, MaxLength, Length);
end;
The message window displays the following:
The MaxStrLen method returns: 30
whereas the StrLen method returns: 7
This shows that the MaxLength method returns the maximum possible length according to the definition of the string variable, whereas StrLen returns the actual length of the text.
See Also
피드백
https://aka.ms/ContentUserFeedback
출시 예정: 2024년 내내 콘텐츠에 대한 피드백 메커니즘으로 GitHub 문제를 단계적으로 폐지하고 이를 새로운 피드백 시스템으로 바꿀 예정입니다. 자세한 내용은 다음을 참조하세요.다음에 대한 사용자 의견 제출 및 보기