segunda-feira, 26 de julho de 2010

Left e right functions q retorna um valor passado pelo separador

Function LsLeftStr(OrigStr, LeftOf ) As String

' ***** return the string to the left of the separator
Dim Pos As Integer
Dim OrigStrLen As Integer

Pos = Instr( Lcase(OrigStr), Lcase(LeftOf) )
OrigStrLen = Len(OrigStr)

If pos>0 Then
LsLeftStr = Left( OrigStr, (Pos-1))
Else
LsLeftStr = OrigStr
End If

End Function



Function LsRightStr(OrigStr, RightOf ) As String

' ***** returns the value to the right of the separator
Dim Pos As Integer
Dim OrigStrLen As Integer
Dim RightOfLen As Integer

Pos = Instr( Lcase(OrigStr), Lcase(RightOf) )
OrigStrLen = Len(OrigStr)
RightOfLen = Len(RightOf)

If Pos>0 Then
LsRightStr = Right( OrigStr, OrigStrLen - (RightOfLen+Pos-1))
Else
LsRightStr = OrigStr
End If
End Function
If pos>0 Then
LeftStr = Left( OrigStr, (Pos-1))
Else
LeftStr = OrigStr
End If

End Function



Function RightStr(OrigStr, RightOf ) As String

' ***** returns the value to the right of the separator
Dim Pos As Integer
Dim OrigStrLen As Integer
Dim RightOfLen As Integer

Pos = Instr( Lcase(OrigStr), Lcase(RightOf) )
OrigStrLen = Len(OrigStr)
RightOfLen = Len(RightOf)

If Pos>0 Then
RightStr = Right( OrigStr, OrigStrLen - (RightOfLen+Pos-1))
Else
RightStr = OrigStr
End If
End Function

Nenhum comentário:

Postar um comentário