Ir para conteúdo
Fórum Script Brasil

Juliano Kurschbauer

Membros
  • Total de itens

    5
  • Registro em

  • Última visita

Sobre Juliano Kurschbauer

Juliano Kurschbauer's Achievements

0

Reputação

  1. Ajustando melhor ficou assim: Public TeclaPress As String Public TeclaPress2 As String Private Sub txtEnviado_Click(sender As Object, e As EventArgs) Handles txtEnviado.Click TeclaPress2 = "" End Sub Private Sub txtEnviado_DoubleClick(sender As Object, e As EventArgs) Handles txtEnviado.DoubleClick sender.SelectAll() End Sub Private Sub txtEnviado_GotFocus(sender As Object, e As EventArgs) Handles txtEnviado.GotFocus sender.SelectAll() TeclaPress2 = "" End Sub Private Sub txtEnviado_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtEnviado.KeyPress Dim allowedChars As String = "0123456789" If allowedChars.IndexOf(e.KeyChar) = -1 And (e.KeyChar <> Chr(8)) Then e.Handled = True End If Dim Posicao As Long = sender.SelectionStart If e.KeyChar = "," Then TeclaPress = "2" TeclaPress2 = "2" sender.SelectionStart = sender.Text.Length - TeclaPress Else If TeclaPress2 = "2" Then TeclaPress = "1" TeclaPress2 = "1" Else If TeclaPress2 = "1" Then TeclaPress = "0" 'TeclaPress2 = "0" Else TeclaPress = "3" End If End If End If If e.KeyChar = Chr(13) Then ' troca enter por o tab SendKeys.Send("{TAB}") ' Tira o som da tecla enter e.Handled = True End If End Sub Private Sub txtEnviado_TextChanged(sender As Object, e As EventArgs) Handles txtEnviado.TextChanged Dim Posicao As Long = sender.SelectionStart Dim PontosInicial As String Dim PontosFinal As String Posicao = Replace(sender.SelectionStart, ".", "") PontosInicial = ContaCaracteresNaString(sender.Text, ".") Dim valor As Double Try valor = Double.Parse(sender.Text) sender.Text = valor.ToString("#,#.00;(#,#.00)") PontosFinal = ContaCaracteresNaString(sender.Text, ".") If TeclaPress = "2" Then sender.SelectionStart = sender.Text.Length - TeclaPress ElseIf TeclaPress = "1" Then sender.SelectionStart = sender.Text.Length - TeclaPress ElseIf TeclaPress = "0" Then sender.SelectionStart = sender.Text.Length ElseIf TeclaPress = "3" Then If PontosInicial <> PontosFinal Then Posicao += 1 End If sender.SelectionStart = Posicao TeclaPress2 = "" End If Catch ex As Exception End Try End Sub Tinha esquecido da Função: Public Function ContaCaracteresNaString(ByVal texto As String, ByVal caracter As String) As Long Dim x As Object x = Split(texto, caracter) ContaCaracteresNaString = UBound(x) End Function
  2. Consegui reproduzir o que queria com os seguintes comandos: Private Sub TxtCartao_Click(sender As Object, e As EventArgs) Handles TxtCartao.Click TxtCartao.SelectAll() TeclaPress2 = "" End Sub Private Sub TxtCartao_GotFocus(sender As Object, e As EventArgs) Handles TxtCartao.GotFocus TxtCartao.SelectAll() TeclaPress2 = "" End Sub Private Sub TxtCartao_KeyPress(sender As Object, e As KeyPressEventArgs) Handles TxtCartao.KeyPress Dim allowedChars As String = "0123456789" If allowedChars.IndexOf(e.KeyChar) = -1 And (e.KeyChar <> Chr(8)) Then e.Handled = True End If Dim Posicao As Long = TxtCartao.SelectionStart If e.KeyChar = "," Then TeclaPress = "2" TeclaPress2 = "2" TxtCartao.SelectionStart = TxtCartao.Text.Length - TeclaPress Else If TeclaPress2 = "2" Then TeclaPress = "1" TeclaPress2 = "1" Else If TeclaPress2 = "1" Then TeclaPress = "0" 'TeclaPress2 = "0" Else TeclaPress = "3" End If End If End If If e.KeyChar = Chr(13) Then ' troca enter por o tab SendKeys.Send("{TAB}") ' Tira o som da tecla enter e.Handled = True End If End Sub Private Sub TxtCartao_Leave(sender As Object, e As EventArgs) Handles TxtCartao.Leave TotalTxt() BtnSalvar.Enabled = True End Sub Private Sub TxtCartao_TextChanged(sender As Object, e As EventArgs) Handles TxtCartao.TextChanged Dim Posicao As Long = TxtCartao.SelectionStart Dim PontosInicial As String Dim PontosFinal As String Posicao = Replace(TxtCartao.SelectionStart, ".", "") PontosInicial = ContaCaracteresNaString(TxtCartao.Text, ".") Dim valor As Double Try valor = Double.Parse(TxtCartao.Text) TxtCartao.Text = valor.ToString("#,#.00;(#,#.00)") PontosFinal = ContaCaracteresNaString(TxtCartao.Text, ".") If TeclaPress = "2" Then TxtCartao.SelectionStart = TxtCartao.Text.Length - TeclaPress ElseIf TeclaPress = "1" Then TxtCartao.SelectionStart = TxtCartao.Text.Length - TeclaPress ElseIf TeclaPress = "0" Then TxtCartao.SelectionStart = TxtCartao.Text.Length ElseIf TeclaPress = "3" Then If PontosInicial <> PontosFinal Then Posicao += 1 End If TxtCartao.SelectionStart = Posicao TeclaPress2 = "" End If Catch ex As Exception End Try End Sub É uma gambiarra, acredito que pode ser aperfeiçoado por alguém com mais conhecimentos, alguém tem alguma sugestão?
  3. Boa tarde pessoal, Estou encontrando dificuldade em formatar uma textbox ao digitar, a ideia principal seria a seguinte: Digamos que eu vá incluir o seguinte valor 15.482,45. sem digitar nada na textbox gostaria de ter o valor inicial de ",00" e conforme incluir os valor ficariam assim... 1,00 15,00 154,00 1.548,00 15.482,00 e somente após clicar na vírgula ele preencher os valores após a ela... 15.482,40 15.482,45 Alguém tem alguma dica de como reproduzir esse exemplo?
  4. Depois de muita procura consegui resolver o problema com a seguinte linha de código: ROW_NUMBER() OVER(PARTITION BY T0.ItemCode ORDER BY T0.ItemCode ASC) Ele conta linha por linha o que mostra 1 para a primeira vez que o item aparece e 2 para a segunda vez, ai foi só fazer um CASE e mostrar o valor do item quando o resultado for '1'
  5. Olá pessoal, sou novo aqui, minha duvida é o seguinte... Possuo um banco onde estou desenvolvendo um select para buscar os dados, porem está retornado algumas informações duplicadas, o motivo é que existem colunas com dados distintos, até ai tudo bem, o problema está no valor dos itens que também se repete, é possível colocar que esse valor aparece apenas na primeira linha exclusiva de cada Item? Anexei uma imagem do Excel para explicar melhor, na coluna P os valores se repetem, gostaria que aparecesse os valores apenas na linha 410 e 427.
×
×
  • Criar Novo...