Display Count of Records

Results 1 to 8 of 8

Thread: Display Count of Records

  1. #1
    Join Date
    Dec 1969
    Posts
    118

    Default Display Count of Records

    Hi,<BR><BR>I am able to display the contents of a text file on the server using OpenTextFile, and would also like to display a count of the number of records in the file. Can someone tell me how to do this, as I&#039m new to ASP? Thanks!<BR><BR>Anthony<BR>gunia@calumet.purdue.edu

  2. #2
    Chris Willey Guest

    Default RE: Display Count of Records

    The only way I know to get a line count for a text file in asp is to do it manually using a loop:<BR><BR>x = 0<BR>Do Until txtFile.AtEndOfStream<BR>x = x + 1<BR>txtFile.SkipLine<BR>Loop<BR><BR>x will then be the number of lines.

  3. #3
    Join Date
    Dec 1969
    Posts
    118

    Default RE: Display Count of Records

    Hi,<BR><BR>I put your code in mine, and now do get a line count. Would you know how I can get a sum count of all records? Here&#039s the code thus far:<BR><BR><BR>Dim objFSO, objTextFile, Count<BR>Set objFSO = CreateObject("Scripting.FileSystemObject")<BR>Set objTextFile = objFSO.OpenTextFile("C:InetPubwwwroot_privateaddre ss.txt")<BR>Count = 0<BR>Do Until objTextFile.AtEndOfStream<BR>Count = Count + 1<BR> Response.Write Count & "&nbsp;" & objTextFile.ReadLine & "<BR>" & vbCrLf<BR>ObjTextFile.SkipLine<BR>Loop<BR><BR>Than ks!<BR><BR>Anthony<BR>

  4. #4
    Chris Willey Guest

    Default RE: Display Count of Records

    I guess I&#039m not clear on what you mean by "records". In a text file, typically a record is delineated by a line break, so a line count would be the same as a record count. Or do you mean something else?


  5. #5
    Bill Anthony Guest

    Default RE: Display Count of Records

    Chris:<BR><BR>I read your post and now I am very interested in knowing what reference material you might have regarding how ASP reads text files. The commands "txtFile.AtEndOfStream" and "txtFile.SkipLine" are nwe to me and I would be very interested in learning more about them. My assumpption is that there is an entire library of such "txtFile.XXXX" commands. I have several uses for textfile handling coming up shortly and would appreciate any assistance you might be able to provide. Thank you in advance!<BR><BR>Bill Anthony

  6. #6
    Join Date
    Dec 1969
    Posts
    118

    Default RE: Display Count of Records

    Chris,<BR><BR>The file I&#039m reading contains only e-mail addresses and is displayed as follows when opened:<BR><BR>something@nowhere.com<BR>heyyou@now here.com<BR>givemeabreak@nowhere.com<BR><BR>I want to count the number of e-mail addresses for this file. This file I&#039m working with is a subscription e-mail file, and will be growing to hundreds of e-mail addresses. I want to be able to not only display the addresses, but give a sum of how many are in the file. Does that help to clarify what I&#039m trying to do? Thanks!<BR><BR>Anthony

  7. #7
    Chris Willey Guest

    Default RE: Display Count of Records

    There are three books I would recommend, in order of complexity:<BR><BR>1) ASP for Dummies (I know, I know, but trust me)<BR>2) Professional Active Server Pages 2.0 (WROX press)<BR>3) ASP Programmer&#039s Reference (also WROX)<BR><BR>You can also check out the excellent articles on the following sites:<BR><BR>www.4guysfromrolla.com<BR>www.active serverpages.com<BR>www.takempis.com<BR><BR>As well as a host of others.

  8. #8
    Chris Willey Guest

    Default RE: Display Count of Records

    Is there one email address per line? If so, a count of lines will be the same thing.

Posting Permissions

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