DICA DE M?SCARA FORMATO TELEFONE (XX) XXXX-XXXX
Venho aqui deixar a dica para máscara no formato do telefone, conforme verifiquei no fórum não existe, então estou deixando aqui:
Public Sub txtTelefone_keyPress(KeyAscii As Integer)
Select Case KeyAscii
Case 48 To 57
If txtTelefone.SelStart = 0 Then txtTelefone.SelText = [Ô]([Ô]
If txtTelefone.SelStart = 3 Then txtTelefone.SelText = [Ô]) [Ô]
If txtTelefone.SelStart = 9 Then txtTelefone.SelText = [Ô]-[Ô]
End Select
End Sub
Public Sub txtTelefone_keyPress(KeyAscii As Integer)
Select Case KeyAscii
Case 48 To 57
If txtTelefone.SelStart = 0 Then txtTelefone.SelText = [Ô]([Ô]
If txtTelefone.SelStart = 3 Then txtTelefone.SelText = [Ô]) [Ô]
If txtTelefone.SelStart = 9 Then txtTelefone.SelText = [Ô]-[Ô]
End Select
End Sub

Creio que o MaskTextbox faça o mesmo serviço utilizando a propriedade mask, mas essa forma é bem interessante também utilizando somente o textbox. (Não sei se o VB6 tem o MaskTextbox, mas o VB.NET já tem e vem pronto, só configurar). Mas eu falo pelos meus amigos que ainda programam em VB6, ajuda e muito isso, tanto para Telefone, como para CEP, só reajustar a quantidade de itens que vai estar na Textbox.
Exatamente, dei uma olhada no MaskTextbox, mas achei que essa que montei seja bem melhor.
Vb6 tem o MaskEdBox idêntico ao do Vbnet.
Mas este formato no textbox ficou Show.
Mas este formato no textbox ficou Show.
Citação::
Vb6 tem o MaskEdBox idêntico ao do Vbnet.
Mas este formato no textbox ficou Show.
Verdade OMAR2011

Fiz o teste no VB.NET e funcionou perfeitamente também, (Claro né, é a mesma linguagem kkk), mas ele tem um efeito diferente do mask, repito as palavras do Omar, Show
Citação::
Fiz o teste no VB.NET e funcionou perfeitamente também, (Claro né, é a mesma linguagem kkk), mas ele tem um efeito diferente do mask, repito as palavras do Omar, Show
Sensacional MOUSER
BOa. Alguem sabe o Formato de CHave de Acesso da NFE em Textbox. ?
xxxx.xxxx.xxxx.xxxx.xxxx.xxxx.xxxx.xxxx.xxxx.xxxx.xxxx
usando Textbox.
xxxx.xxxx.xxxx.xxxx.xxxx.xxxx.xxxx.xxxx.xxxx.xxxx.xxxx
usando Textbox.
Citação::
BOa. Alguem sabe o Formato de CHave de Acesso da NFE em Textbox. ?
xxxx.xxxx.xxxx.xxxx.xxxx.xxxx.xxxx.xxxx.xxxx.xxxx.xxxx
usando Textbox.
é esta aqui JOHNSTEVE:
Public Sub txtChaveDeAcesso_keyPress(KeyAscii As Integer)
Select Case KeyAscii
Case 48 To 57
[ô]If txtChaveDeAcesso.SelStart = 0 Then txtChaveDeAcesso.SelText = [Ô].[Ô]
If txtChaveDeAcesso.SelStart = 4 Then txtChaveDeAcesso.SelText = [Ô].[Ô]
If txtChaveDeAcesso.SelStart = 9 Then txtChaveDeAcesso.SelText = [Ô].[Ô]
If txtChaveDeAcesso.SelStart = 14 Then txtChaveDeAcesso.SelText = [Ô].[Ô]
If txtChaveDeAcesso.SelStart = 19 Then txtChaveDeAcesso.SelText = [Ô].[Ô]
If txtChaveDeAcesso.SelStart = 24 Then txtChaveDeAcesso.SelText = [Ô].[Ô]
If txtChaveDeAcesso.SelStart = 29 Then txtChaveDeAcesso.SelText = [Ô].[Ô]
If txtChaveDeAcesso.SelStart = 34 Then txtChaveDeAcesso.SelText = [Ô].[Ô]
If txtChaveDeAcesso.SelStart = 39 Then txtChaveDeAcesso.SelText = [Ô].[Ô]
If txtChaveDeAcesso.SelStart = 44 Then txtChaveDeAcesso.SelText = [Ô].[Ô]
If txtChaveDeAcesso.SelStart = 49 Then txtChaveDeAcesso.SelText = [Ô].[Ô]
If txtChaveDeAcesso.SelStart = 55 Then txtChaveDeAcesso.SelText = [Ô].[Ô]
End Select
End Sub
E na propriedade do [ô]Text[ô] define o [ô]MaxLenght = 54[ô].
Essa tua função de formatar telefone obriga o usuário a digitar o código de área.
Desenvolvi a função abaixo que formata o telefone, mesmo que o usuário não digite o código de área, deixando o trabalho de digitação mais rápido
Private Function FormatarFone(NumTel As String) As String
Dim S As String = [Ô][Ô]
[ô]Extraio somente os números da função
For Each C As Char In NumTel
If Char.IsDigit(C) Then S += C
Next
If S.Length < 8 Then [ô]Não possui caracteres suficientes
Return [Ô][Ô]
Else
S = S.PadLeft(10, [Ô]5[Ô]) [ô]Preencho a string com os dÃgitos do ódigo de área padrão, caso não seja informado
If S.Length > 10 Then S = S.Substring(S.Length - 10)
S = [Ô]([Ô] + S.Insert(6, [Ô]-[Ô]).Insert(2, [Ô])[Ô])
Return S
End If
End Function
Veja se ajuda. Vi que vc usa o VB6. é só reescrevê-la
Desenvolvi a função abaixo que formata o telefone, mesmo que o usuário não digite o código de área, deixando o trabalho de digitação mais rápido
Private Function FormatarFone(NumTel As String) As String
Dim S As String = [Ô][Ô]
[ô]Extraio somente os números da função
For Each C As Char In NumTel
If Char.IsDigit(C) Then S += C
Next
If S.Length < 8 Then [ô]Não possui caracteres suficientes
Return [Ô][Ô]
Else
S = S.PadLeft(10, [Ô]5[Ô]) [ô]Preencho a string com os dÃgitos do ódigo de área padrão, caso não seja informado
If S.Length > 10 Then S = S.Substring(S.Length - 10)
S = [Ô]([Ô] + S.Insert(6, [Ô]-[Ô]).Insert(2, [Ô])[Ô])
Return S
End If
End Function
Veja se ajuda. Vi que vc usa o VB6. é só reescrevê-la
Show PLUGSOFTSM

Tópico encerrado , respostas não são mais permitidas