Results 1 to 1 of 1

Thread: Reading in the contents of a text file

Threaded View

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Apr 2004
    Location
    Belfast
    Posts
    116

    Reading in the contents of a text file

    Hi All, im trying to readin the last line of a file and put it in a label in eVB 3.0: heres what ive tried so far, ive basically played around with the code from my VB6 app, but it dosent seem to like LOF:

    VB Code:
    1. Dim strText, arLines() As String, N As Integer
    2.  
    3.     File1.Open "/My Documents/Business/invoice.txt", fsModeAppend
    4.    
    5.         'read entire file into string variable
    6.         strText = Input(LOF(1), File1)
    7.         'split entire text on [Carriage Return]+[Line Feed] characters
    8.         'and populate string array
    9.         arLines = Split(strText, vbNewLine)
    10.    File1.Close
    11.    
    12.     For N = UBound(arLines) To LBound(arLines) Step -1
    13.         If Not arLines(N) = vbNullString Then
    14.             Product_Choice.label5.Caption = arLines(N)
    15.             Product_Choice.label5.Caption = Product_Choice.label5.Caption + 1
    16.                 File1.Open "/My Documents/Business/invoice.txt", fsModeAppend
    17.                 File1.LinePrint Product_Choice.label5.Caption
    18.                 File1.Close
    19.                
    20.             Exit For
    21.         End If
    22.     Next N

    anyone any ideas, im a bit new to eVB so excuse anything glaringly obvious!!!
    Last edited by paulhenderson; Apr 10th, 2006 at 03:38 PM.

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