Vie Jun 03, 2011 10:12 pm
- Código:
Public Function aLTrim(A As String)
On Error Resume Next
'============================================================'
' AX: aLTrim '
' Uso: Call aLTrim(" Texto") '
'============================================================'
Dim b As Long
Dim c As Long
If Len(A) = 0 Then Exit Function
For b = 1 To Len(A) Step 1
If Mid(A, b, 1) <> Chr(32) Then c = b: Exit For
Next b
aLTrim = Mid(A, c, Len(A) - (c - 1))
End Function
Si el Texto fuera: " Hola mundo" entonces el resultado sería "Hola mundo"
- Código:
Public Function aRTrim(A As String)
On Error Resume Next
'============================================================'
' AX: aRTrim '
' Uso: Call aRTrim("Texto ") '
'============================================================'
Dim i As Long
Dim k As Long
If Len(A) = 0 Then Exit Function
For i = Len(A) To 1 Step -1
If Mid(A, i, 1) <> Chr(32) Then k = i: Exit For
Next i
aRTrim = Mid(A, 1, Len(A) - (Len(A) - k))
End Function
- Código:
Public Function aTrim(A As String)
On Error Resume Next
'============================================================'
' AX: aTrim '
' Uso: Call aTrim(" Texto ") '
'============================================================'
Dim f As Long
Dim g As Long
Dim h As Long
Dim i As String
If Len(A) = 0 Then Exit Function
For f = 1 To Len(A) Step 1
If Mid(A, f, 1) <> Chr(32) Then g = f: Exit For
Next f
i = Mid(A, g, Len(A) - (g - 1))
For f = Len(i) To 1 Step -1
If Mid(i, f, 1) <> Chr(32) Then h = f: Exit For
Next f
aTrim = Mid(i, 1, Len(i) - (Len(i) - h))
End Function