RETIRAR ZERO A ESQUERDA
Pessoal, na minha tabela no campo Contrato tenho varios registros q tem o zero no inicio conforme exemplo abaixo:
06838.0-AH-0396
preciso de uma função q retire esse primeiro zero quando houver quando carrego o Grid. Pesquisei na Net e achei algumas ma não deu resultado.
Preciso retirar o zero aqui:
GridMovimento.TextMatrix(Row, 0) = !Contrato
Funções Exemplo: nehuma funcionou!
Public Function removeZero(strField As String) As String
[ô]If the first character is zero, proceed
If (strField.Substr(0, 1) = [Ô]0[Ô]) Then
[ô]remove the first character which should be a zero
[ô]return the new string
removeZero = Right(strField, (Len(strField) - 1))
End If
End Function
Private Function zeros_esquerda(ByVal str As String, ByVal qtd As Integer) As String
Dim aux%, i%
aux = Len(str)
For i = 1 To (qtd - aux)
str = [Ô]0[Ô] & str
Next
zeros_esquerda = str
End Function
06838.0-AH-0396
preciso de uma função q retire esse primeiro zero quando houver quando carrego o Grid. Pesquisei na Net e achei algumas ma não deu resultado.
Preciso retirar o zero aqui:
GridMovimento.TextMatrix(Row, 0) = !Contrato
Funções Exemplo: nehuma funcionou!
Public Function removeZero(strField As String) As String
[ô]If the first character is zero, proceed
If (strField.Substr(0, 1) = [Ô]0[Ô]) Then
[ô]remove the first character which should be a zero
[ô]return the new string
removeZero = Right(strField, (Len(strField) - 1))
End If
End Function
Private Function zeros_esquerda(ByVal str As String, ByVal qtd As Integer) As String
Dim aux%, i%
aux = Len(str)
For i = 1 To (qtd - aux)
str = [Ô]0[Ô] & str
Next
zeros_esquerda = str
End Function
tenta assim
if left(var, 1) = [Ô]0[Ô] then
var = right(var, len(var) -1)
end if
se for para tirar só o primeiro zero da esquerda, da certo =P
bem simples mas pelo que entendi é isso que voce precisa
if left(var, 1) = [Ô]0[Ô] then
var = right(var, len(var) -1)
end if
se for para tirar só o primeiro zero da esquerda, da certo =P
bem simples mas pelo que entendi é isso que voce precisa
Public Function RetiraZero(Texto As String) As String
If Mid(Texto, 1, 1) = [Ô]0[Ô] Then
RetiraZero = Mid(Texto, 2, Len(Texto))
Else
RetiraZero = Texto
End if
End Function
Obs: Não testei.
If Mid(Texto, 1, 1) = [Ô]0[Ô] Then
RetiraZero = Mid(Texto, 2, Len(Texto))
Else
RetiraZero = Texto
End if
End Function
Obs: Não testei.
mais uma
MsgBox Replace([Ô]06838.0-AH-0396[Ô], [Ô]0[Ô], [Ô][Ô], 1, 2)
MsgBox Replace([Ô]06838.0-AH-0396[Ô], [Ô]0[Ô], [Ô][Ô], 1, 2)
Tópico encerrado , respostas não são mais permitidas