Results 1 to 3 of 3

Thread: [RESOLVED] how to capture a string from a .txt file

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2006
    Posts
    6

    Resolved [RESOLVED] how to capture a string from a .txt file

    Hello :

    i am new to vb, i am using vb 6.0 , i have an assigment , i have to save in a string var or array , a lots of data . the thing is i already open and read the file , no problem . now i don't know how to set a string var. here is the .txt file

    RFC: Fecha :
    REPORTE
    RP : Hora : 10:25:31
    Filtro: Ultimo Cálculo
    ********************************************************************************
    E M P L E A D O
    CLAVE NOMBRE FECHA DE ALTA JORNADA TIPO SAL
    --------------------------------------------------------------------------------
    P E R C E P C I O N E S DEDUCCIONES Y DATOS
    CLV. DESCRIPCION IMPORTE CLV. DESCRIPCION IMPORTE NETO
    ********************************************************************************

    00001224 xxxxxxxxxxxxxxxxxxxx 06/18/2005 2 días Mixto
    concept1: xxxxxxxxxx concept1: 03-97-79-0593-8 concept1: xxxxxx
    concept1 900.00 concept4 6.94
    concept2 37.50 concept5 0.35
    concept3 41.94 concept6 6.0000*
    AJUSTE (+) 0.85 TOTAL 32.9300*
    concept7 150.0000*
    S. concept8 48.6700*

    concept1: 980.29 concept1 : 7.29 973.00


    i have to put the concepts in string var or an array . can some one point me in the rigth direction ?

    THANKS IN ADVENCED
    Last edited by Hack; May 2nd, 2006 at 08:14 AM. Reason: Added [RESOLVED] to thread title and green "resolved" checkmark

  2. #2
    Lively Member
    Join Date
    Jun 2005
    Posts
    116

    Re: how to capture a string from a .txt file

    VB Code:
    1. Public Function GetStringBetween(ByVal InputText As String, _
    2.     ByVal StartText As String, _
    3.     ByVal EndText As String, _
    4.     Optional ByVal StartPosition = 1) As String
    5.  
    6.     Dim lnTextStart As Long
    7.     Dim lnTextEnd As Long
    8.  
    9.     lnTextStart = InStr(StartPosition, InputText, StartText, vbTextCompare) + Len(StartText)
    10.     lnTextEnd = InStr(lnTextStart, InputText, EndText, vbTextCompare)
    11.     If lnTextStart >= (StartPosition + Len(StartText)) And lnTextEnd > lnTextStart Then
    12.         GetStringBetween = Mid$(InputText, lnTextStart, lnTextEnd - lnTextStart)
    13.     Else
    14.         GetStringBetween = ""
    15.     End If
    16.    
    17. End Function

    This function should help you. You can pass in the start and ending point and it will get the info in between.

    Usage:
    VB Code:
    1. Yourinfo = GetStringBetween(YourTxtString, start, end)

  3. #3

    Thread Starter
    New Member
    Join Date
    Apr 2006
    Posts
    6

    Re: how to capture a string from a .txt file

    Thanks A Lot !!!!!!!!!!!!!!!!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width