DICA DE M?SCARA FORMATO TELEFONE (XX) XXXX-XXXX

MILTONSILVA94 06/04/2016 12:55:25
#460581
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

MOUSER 06/04/2016 14:45:38
#460603
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.
MILTONSILVA94 06/04/2016 15:05:41
#460607
Exatamente, dei uma olhada no MaskTextbox, mas achei que essa que montei seja bem melhor.
OMAR2011 06/04/2016 15:22:36
#460608
Vb6 tem o MaskEdBox idêntico ao do Vbnet.
Mas este formato no textbox ficou Show.
MILTONSILVA94 06/04/2016 17:01:02
#460624
Citação:

:
Vb6 tem o MaskEdBox idêntico ao do Vbnet.
Mas este formato no textbox ficou Show.



Verdade OMAR2011

MOUSER 06/04/2016 17:28:14
#460633
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
MILTONSILVA94 07/04/2016 07:23:41
#460647
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
JOHNSTEVE 07/04/2016 07:44:18
#460649
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.

MILTONSILVA94 07/04/2016 10:40:34
#460660
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[ô].
PLUGSOFTSM 07/04/2016 11:15:11
#460668
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
MILTONSILVA94 07/04/2016 11:28:17
#460671
Show PLUGSOFTSM
Página 1 de 2 [14 registro(s)]
Tópico encerrado , respostas não são mais permitidas