Foros del Web » Programación para mayores de 30 ;) » Programación General »

[SOLUCIONADO] VB6: Problema salto de linea

Estas en el tema de VB6: Problema salto de linea en el foro de Programación General en Foros del Web. tengo las siguientes dos funciones Código: Public Sub ExportDBTableToText2(rs As Recordset, TextFile As String) Dim FieldCount As Integer Dim i As Integer Dim tmp As ...
  #1 (permalink)  
Antiguo 24/11/2016, 21:44
 
Fecha de Ingreso: abril-2005
Ubicación: Piura - Perú
Mensajes: 189
Antigüedad: 18 años, 11 meses
Puntos: 0
VB6: Problema salto de linea

tengo las siguientes dos funciones

Código:
Public Sub ExportDBTableToText2(rs As Recordset, TextFile As String)

Dim FieldCount As Integer
Dim i As Integer
Dim tmp As String

Open TextFile For Append As #1

Do Until rs.EOF
    tmp = rs.GetString(adClipString, , "|", "|" & vbCrLf)
    If rs.EOF Then
        tmp = Left$(tmp, Len(tmp) - 1)
    End If

Print #1, tmp
Loop

Close #1

End Sub

y esta otra funcion :

Código:
Public Sub ExportDBTableToText3(rs As Recordset, TextFile As String)
Dim FieldCount As Integer
Dim i As Integer
    Open TextFile For Append As #1
        Print #1, rs.GetString(adClipString, , "|", "|" & vbCrLf)
    Close #1
End Sub
El problema esta que el archivo que genera tiene al final saltos de lineas innecesarios, yo solo deseo que se use salto de linea para separar renglones al final no es necesario ningún salto de linea.. alguna idea ?.. gracias
  #2 (permalink)  
Antiguo 27/11/2016, 12:47
 
Fecha de Ingreso: abril-2005
Ubicación: Piura - Perú
Mensajes: 189
Antigüedad: 18 años, 11 meses
Puntos: 0
Respuesta: VB6: Problema salto de linea

Se soluciono con esta codigo al final

Código vb:
Ver original
  1. Function sfuncEndVBCRLFremoved(strSource As String, Optional bTrimSource As Boolean = True) As String
  2. On Error GoTo err_h:
  3.  
  4. Dim s As String
  5. Dim iLen As Integer
  6.  
  7. If bTrimSource Then strSource = Trim$(strSource)
  8.  
  9. testPoint:
  10.  
  11. 'get last two characters of string
  12. s = Mid$(strSource, Len(strSource) - 1, 2)
  13.  
  14. 'len of [strSource]
  15. iLen = Len(strSource)
  16.  
  17. 'if last two characters are carriage return and
  18. 'line feed then trim off the last 2 characters
  19. If s = vbCrLf Then
  20.          strSource = Mid$(strSource, 1, (iLen - 2))
  21.          GoTo testPoint: 'test last two characters
  22. End If
  23.  
  24. 'return with trailing carriage returns removed
  25. sfuncEndVBCRLFremoved = strSource
  26.  
  27.  
  28. Exit Function
  29. err_h:
  30. With Err
  31.      If .Number <> 0 Then
  32.             'create .bas named [ErrHandler]  see http://vb6.info/h764u
  33.            ErrHandler.ReportError Date & ": Str.sfuncEndVBCRLFremoved." & Err.Number & "." & Err.Description
  34.             Resume Next
  35.       End If
  36. End With
  37. End Function

Etiquetas: salto, vb6
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 08:32.