Results 1 to 13 of 13

Thread: Text File Writing

  1. #1

    Thread Starter
    Fanatic Member Dim's Avatar
    Join Date
    Jul 2000
    Posts
    620
    Can someone plz explain how i would find out when 30lines have been writen to a text file? So every 30 lines, a msg box would pop up.

    Thanx,
    D!m
    Dim

  2. #2
    Hyperactive Member
    Join Date
    May 2000
    Posts
    344

    mabye this

    I know there has to be a better way to do it but if you get no replies then i guess a way is better then no way.
    Dim sFirst, sSecond, sThird........, sThirty

    Open "\file.txt" For Input As #7
    Line Input #7, sfirst
    If sthirty = "" Then
    'sit on ur ass
    else
    Msgbox "There is something on line 30!"
    Close #7
    -RaY
    VB .Net 2010 (Ultimate)

  3. #3
    Lively Member
    Join Date
    Jul 2000
    Posts
    104
    Maybe...

    Write a function that does the writing to the file. It would have a for...next loop in with a counter to 30 and then message box would appear after the looping is done.

    In the procedure that calls the function you could test to see if you need to write more or proceed when the function returns.

    Just a suggestion.

  4. #4
    Guest

    Lightbulb

    Here's a way using mod which returns only the remainder of a division:

    Dim x As Integer
    Dim strMsg As String
    Dim strInfo As String

    x = 0 ' a counter
    strMsg = "" ' message for messagebox

    Open URFILE For Input As #1
    ' read the file until you get to EOF
    Do Until EOF(1)

    ' if not at eof, then read line and increment counter
    Line Input #1, strInfo
    x = x + 1

    If x Mod 30 = 0 Then
    ' x is evenly divisible by 30, ie a multiple
    If strMsg = "" Then
    ' format the initial message
    strMsg = "30 lines have been read"
    Else
    ' format subsequent messages
    strMsg = "30 more lines have been read"
    End If ' strMsg = ""

    ' display the message box
    MsgBox strMsg

    End If ' mod(x)

    Loop
    Close #1

    MsgBox "A total of " & Format(x, "0") & " lines were read"


  5. #5
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    How are you writing the lines?
    What is your code?
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  6. #6
    Frenzied Member
    Join Date
    Aug 1999
    Location
    Santa Clara, Ca , 95058
    Posts
    1,105

    Re: mabye this

    Originally posted by fallnwrld
    I know there has to be a better way to do it but if you get no replies then i guess a way is better then no way.
    Dim sFirst, sSecond, sThird........, sThirty

    Open "\file.txt" For Input As #7
    Line Input #7, sfirst
    If sthirty = "" Then
    'sit on ur ass
    else
    Msgbox "There is something on line 30!"
    Close #7
    A better approach would be to have a counter that increments every time you _write_ a RECORD.


    dim I as long
    dim sText as string

    i=1
    Open "file.txt" for output as #6
    for i = 1 to endofprint
    print #6, text
    if i mod 30 = 0 then msgbox "30 (more) records have been processed."
    next i

  7. #7
    Guest
    Code:
    dim i as integer
    dim LineStr as string
    
    open Filename for input #1
    
    do while not EOF(1)
    line input #1, LineStr
    i = i+1
    if i = 30 then 
    msgbox "yo what up, this here file is at least 30 lines long!"
    exit do
    loop
    close #1

  8. #8
    Frenzied Member
    Join Date
    Aug 1999
    Location
    Santa Clara, Ca , 95058
    Posts
    1,105
    Almost, Woss. You'll only report the first 30 lines, not every 30 lines.

  9. #9
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946
    if i = 30 then
    i = 1
    msgbox "bla bla"
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  10. #10
    Frenzied Member
    Join Date
    Aug 1999
    Location
    Santa Clara, Ca , 95058
    Posts
    1,105
    Forgot your end if, Wayne.

  11. #11
    Hyperactive Member
    Join Date
    May 2000
    Posts
    344

    lol

    Jhaus your a big help, has any of these techniques helped? Let us know!
    -RaY
    VB .Net 2010 (Ultimate)

  12. #12

    Thread Starter
    Fanatic Member Dim's Avatar
    Join Date
    Jul 2000
    Posts
    620
    I did exactly what HeSaidJoe suggested...and i think it's probably the best way.

    Thanx guys,
    D!m
    Dim

  13. #13
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    it was wossname that did the trick with code....I just corrected an oversight it his/her code...
    credit is not due me, but thanks for the thought.

    All the best.
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

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