# Function Reference

# _GUICtrlRichEdit_GetTextLength

Get the length of the whole text in the control

#include <GuiRichEdit.au3>
_GUICtrlRichEdit_GetTextLength ( $hWnd [, $bExact = True [, $bChars = False [, $iUseCrLf = 1]]] )

## Parameters

$hWnd | Handle to the control
$bExact | [optional] True - Return the exact length False - return at least the number of characters in the control (faster) Default: exact length
$bChars | [optional] True - return length in characters False - return length in bytes Default: bytes
$iUseCrLf | [optional] 1 - End of line counting = 2 (default) 0 - End of line counting = 1

## Return Value

Success: | the length, in bytes or characters.
Failure: | 0 and sets the @error flag to non-zero.
@error: | 101 - $hWnd is not a handle 102 - $bExact must be True or False 103 - $bChars must be True or False

## See Also

Search EM_GETTEXTLENGTHEX in MSDN Library.

## Example

    #include <GUIConstantsEx.au3>
    #include <GuiRichEdit.au3>
    #include <WindowsStylesConstants.au3>

    Global $g_idLbl_Msg

    Example()

    Func Example()
        Local $hGui, $iMsg, $hRichEdit
        $hGui = GUICreate("Example (" & StringTrimRight(@ScriptName, StringLen(".exe")) & ")", 320, 350, -1, -1)
        $hRichEdit = _GUICtrlRichEdit_Create($hGui, "This is a test.", 10, 10, 300, 220, _
                BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))
        $g_idLbl_Msg = GUICtrlCreateLabel("", 10, 235, 300, 60)
        GUISetState(@SW_SHOW)

        _GUICtrlRichEdit_AppendText($hRichEdit, @CRLF & "This is appended text.")

        Report("There are " & _GUICtrlRichEdit_GetTextLength($hRichEdit, True, True) & _
                " characters in the control")

        While True
            $iMsg = GUIGetMsg()
            Select
                Case $iMsg = $GUI_EVENT_CLOSE
                    _GUICtrlRichEdit_Destroy($hRichEdit) ; needed unless script crashes
                    ; GUIDelete()   ; is OK too
                    Exit
            EndSelect
        WEnd
    EndFunc   ;==>Example

    Func Report($sMsg)
        GUICtrlSetData($g_idLbl_Msg, $sMsg)
    EndFunc   ;==>Report