Partilhar via


Objeto TextBox (Script de Formulários do Outlook)

Exibe informações de um usuário ou de um conjunto organizado de dados.

Comentários

Uma TextBox é o controle mais comumente usado para exibir informações digitadas por um usuário. Além disso, pode exibir um conjunto de dados, como uma tabela, consulta, planilha ou resultado de cálculo. Se uma TextBox estiver ligada a uma fonte de dados, alterar o conteúdo da TextBox também alterará o valor da fonte de dados associada.

Uma formatação aplicada a qualquer parte do texto em um TextBox afetará todo o texto no controle. Por exemplo, se você alterar a fonte ou o tamanho de ponto de qualquer caractere no controle, a alteração afetará todos os caracteres no controle.

A propriedade padrão de um TextBox é a propriedade Value.

Dicas sobre como usar caixas de texto

O TextBox é um controle flexível governado pelas seguintes propriedades: Text, MultiLine, WordWrap e AutoSize.

Text contém o texto exibido na caixa de texto.

MultiLine controla se o TextBox pode exibir o texto como uma linha individual ou como várias linhas. Os caracteres novos identificam onde termina uma linha e começa outra. Se MultiLine for False (valor padrão), o texto será truncado em vez de quebrar.

WordWrap permite à TextBox quebrar linhas de texto mais longas do que a TextBox em linhas mais curtas que se encaixem nela. O valor padrão é True.

Se não utilizar o WordWrap, a Caixa de Texto inicia uma nova linha de texto quando encontra um caráter de nova linha no texto. Se o WordWrap estiver desativado, pode ter linhas de texto que não cabem completamente na Caixa de Texto. A Caixa de Texto apresenta as partes de texto que cabem dentro da respetiva largura e trunca as partes do texto que não cabem. WordWrap só se aplicará quando MultiLine for True.

AutoSize controla se o TextBox se ajusta para exibir todo o texto. Quando AutoSize é usada com um TextBox, a largura do TextBox se reduz ou expande de acordo com a quantidade de texto no TextBox e com o tamanho da fonte usada para exibir o texto. O valor padrão é False.

AutoSize funciona bem nas seguintes situações:

  • Exibir uma legenda de uma ou mais linhas.

  • Exibir o conteúdo de uma TextBox com uma só linha.

  • Exibindo o conteúdo de um TextBox com várias linhas que seja somente leitura para o usuário.

Evite utilizar AutoSize com uma TextBox vazia que também utilize as propriedades MultiLine e WordWrap. Quando o usuário digitar texto em uma TextBox com essas propriedades, a TextBox automaticamente se dimensionará como uma caixa longa e estreita, com um caractere de largura e o comprimento da linha de texto.

Métodos

Nome Descrição
Copy Copies the contents of an object to the Clipboard.
Cut Removes selected information from an object and transfers it to the Clipboard.
Paste Transfere o conteúdo da Área de transferência para um objeto.

Propriedades

Nome Descrição
AutoSize Returns or sets a Boolean that specifies whether an object automatically resizes to display its entire contents. Leitura/gravação.
AutoTab Devolve ou define um Booleano que especifica se um separador automático ocorre quando um utilizador introduz o número máximo permitido de carateres numa Caixa de Texto. Leitura/gravação.
AutoWordSelect Returns or sets a Boolean that specifies whether the basic unit used to extend a selection is a word or a single character. Leitura/gravação.
BackColor Returns or sets a Long that specifies the background color of the object. Leitura/gravação.
BackStyle Returns or sets an Integer that specifies the background style for an object. Leitura/gravação.
BorderColor Returns or sets a Long that specifies the border color of an object. Leitura/gravação.
BorderStyle Returns or sets an Integer that specifies the type of border of the control. Leitura/gravação.
CanPaste Returns a Boolean that specifies whether the Clipboard contains data that the object supports. Somente leitura.
CurLine Returns or sets a Long that represents the current line of a control. Leitura/gravação.
CurTargetX Returns a Long that represents the preferred horizontal position of the insertion point in a multiline TextBox. Somente leitura.
CurX Returns or sets a Long that represents the current horizontal position of the insertion point in a multiline TextBox. Leitura/gravação.
DragBehavior Returns or sets an Integer that specifies whether the system enables the drag-and-drop feature for the control. Leitura/gravação.
Enabled Returns or sets a Boolean that specifies whether a control can receive the focus and respond to user-generated events. Leitura/gravação.
EnterFieldBehavior Returns or sets an Integer that specifies the selection behavior when entering a TextBox. Leitura/gravação.
EnterKeyBehavior Devolve ou define um Booleano que define o efeito de premir ENTER numa Caixa de Texto. Leitura/gravação.
ForeColor Returns or sets a Long that specifies the foreground color of an object. Leitura/gravação.
HideSelection Returns or sets a Boolean that specifies whether selected text remains highlighted when a control does not have the focus. Leitura/gravação.
IMEMode Returns or sets an Integer that specifies the default run-time mode of the Input Method Editor (IME) for a control. Leitura/gravação.
IntegralHeight Returns or sets a Boolean that specifies whether a TextBox displays full lines of text or partial lines. Leitura/gravação.
LineCount Returns a Long that specifies the number of text lines in a TextBox. Somente leitura.
Locked Returns or sets a Boolean that specifies whether a control can be edited. Leitura/gravação.
MaxLength Devolve ou define um Valor Longo que especifica o número máximo de carateres que um utilizador pode introduzir numa Caixa de Texto. Leitura/gravação.
MouseIcon Returns a String that represents the full path name of a custom icon that is to be assigned to the control. Somente leitura.
MousePointer Returns or sets an Integer that specifies the type of pointer displayed when the user positions the mouse over a particular object. Leitura/gravação.
MultiLine Returns or sets a Boolean that specifies whether a control can accept and display multiple lines of text. Leitura/gravação.
PasswordChar Returns or sets a String that specifies a placeholder character to be displayed instead of the characters actually entered in a TextBox. Leitura/gravação.
ScrollBars Returns or sets an Integer that specifies whether a control has vertical scroll bars, horizontal scroll bars, or both. Leitura/gravação.
SelectionMargin Returns or sets a Boolean that specifies whether the user can select a line of text by clicking in the region to the left of the text. Leitura/gravação.
SelLength Devolve ou define um Valor Longo que representa o número de carateres selecionados numa Caixa de Texto. Leitura/gravação.
SelStart Returns or sets a Long that represents the starting point of selected text, or the insertion point if no text is selected. Leitura/gravação.
SelText Returns or sets a String that represents the selected text of a control. Leitura/gravação.
SpecialEffect Returns or sets an Integer that specifies the visual appearance of an object. Leitura/gravação.
TabKeyBehavior Returns or sets a Boolean that specifies whether tabs are allowed in the edit region. Leitura/gravação.
Text Returns or sets a String that specifies text in the control. Leitura/gravação.
TextAlign Returns or sets an Integer that specifies how text is aligned in a control. Leitura/gravação.
TextLength Devolve um Valor Longo que representa o comprimento, em número de carateres, do texto na região de edição de uma Caixa de Texto. Somente leitura.
Valor Returns or sets a Variant that specifies text in the edit region. Leitura/gravação.
WordWrap Returns or sets a Boolean that specifies whether the contents of a control automatically wrap at the end of a line and the control expands to fit the text. Leitura/gravação.

Suporte e comentários

Tem dúvidas ou quer enviar comentários sobre o VBA para Office ou sobre esta documentação? Confira Suporte e comentários sobre o VBA para Office a fim de obter orientação sobre as maneiras pelas quais você pode receber suporte e fornecer comentários.