Página 1 de 1

TextBox Só Com Determinado Formato

Enviado: 22 Mar 2023 às 16:50
por PedroBB
Pessoal,
Preciso que uma TextBox permita apenas digitação com Valores tipo VALE3, ou seja, letras nos 4 primeiros caracteres, e Número no 5º e último caracter.

Grato,
Pedro


Obs: postei também em: http://www.tomasvasquez.com.br/forum/vi ... =20&t=8340

Re: TextBox Só Com Determinado Formato

Enviado: 23 Mar 2023 às 08:52
por osvaldomp
Disponibilize o arquivo Excel com a TextBox.

Re: TextBox Só Com Determinado Formato

Enviado: 23 Mar 2023 às 09:36
por PedroBB
Segue arquivo anexo.

Re: TextBox Só Com Determinado Formato

Enviado: 23 Mar 2023 às 11:19
por osvaldomp
FÓRUM ZUADO DE NOVO! NÃO ACEITA FORMATAÇÃO DE TEXTO, NÃO ACEITA INSERÇÃO DE CODE, NÃO ACEITA "OBRIGADO".

Private Sub TextBox1_Change()
If TextBox1.Text = "" Then Exit Sub
If Len(TextBox1.Text) <= 4 Then
If Not Right(TextBox1.Text, 1) Like "[a-zA-Z]" Then 'aceita letras minúsculas e maiúsculas
TextBox1.Text = Left(TextBox1.Text, Len(TextBox1.Text) - 1)
End If
ElseIf Len(TextBox1.Text) = 5 Then
If Not Right(TextBox1.Text, 1) Like "[0-9]" Then
TextBox1.Text = Left(TextBox1.Text, Len(TextBox1.Text) - 1)
End If
Else: TextBox1.Text = Left(TextBox1.Text, Len(TextBox1.Text) - 1)
End If
End Sub

"[A-Z]" ~~~> aceita somente maiúsculas

Re: TextBox Só Com Determinado Formato

Enviado: 23 Mar 2023 às 13:04
por PedroBB
osvaldomp escreveu: 23 Mar 2023 às 11:19 FÓRUM ZUADO DE NOVO! NÃO ACEITA FORMATAÇÃO DE TEXTO, NÃO ACEITA INSERÇÃO DE CODE, NÃO ACEITA "OBRIGADO".

Private Sub TextBox1_Change()
If TextBox1.Text = "" Then Exit Sub
If Len(TextBox1.Text) <= 4 Then
If Not Right(TextBox1.Text, 1) Like "[a-zA-Z]" Then 'aceita letras minúsculas e maiúsculas
TextBox1.Text = Left(TextBox1.Text, Len(TextBox1.Text) - 1)
End If
ElseIf Len(TextBox1.Text) = 5 Then
If Not Right(TextBox1.Text, 1) Like "[0-9]" Then
TextBox1.Text = Left(TextBox1.Text, Len(TextBox1.Text) - 1)
End If
Else: TextBox1.Text = Left(TextBox1.Text, Len(TextBox1.Text) - 1)
End If
End Sub

"[A-Z]" ~~~> aceita somente maiúsculas
Sensacional!!!!
Muito obrigado, Osvaldo!