Results 1 to 10 of 10

Thread: Can Anyone help me here? (Text problem)

  1. #1

    Thread Starter
    Member
    Join Date
    Aug 2000
    Posts
    52
    I need to create and append a logfile in my application.

    It needs to record information from a textbox containing the date and time and also the Username (another txt box).

    This file i believe needs to utilise the append command as it shoudl be ongoing not refreshing.

    Any help is more than appreciated as this is my final bug bear in a rather tidy security application.


    Regards
    Morpheus.

  2. #2
    Guest
    I do not understand your question. Did you need help with how to save the file? If so:
    Code:
    Open "Log" For Append As #1
    Print #1, txtDate, txtUserName
    Close #1

  3. #3

    Thread Starter
    Member
    Join Date
    Aug 2000
    Posts
    52
    Thanks for the heads up Megatron, i was 90 % the way there with it, just needed to change open to append.

    NB; Excellent Nick.

    Thankyou.
    m.

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

    <?>

    [code]
    ' just in case you have not useed this before,
    ' don't forget to use the file path

    Open "FilePath\Log.txt" For Append As #1
    Print #1, txtDate, txtUserName
    Close #1
    [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

  5. #5
    Lively Member
    Join Date
    May 1999
    Location
    belgium
    Posts
    74
    Is it also possible delete the first x-lines in a logfile?

  6. #6
    Evil Genius alex_read's Avatar
    Join Date
    May 2000
    Location
    Espoo, Finland
    Posts
    5,538
    VB Code:
    1. Private Sub Command1_Click()
    2.  
    3.     Dim strFileText As String
    4.    
    5.     Open "C:\Path\LogFile.txt" For Append As #1
    6.    
    7.         [color=green] 'Loop throught the current file lines saving them to a string.[/color]
    8.         Do While Not EOF(1)
    9.    
    10.             strFileText = strFileText & Input(LOF(1), 1)
    11.        
    12.         Loop
    13.    
    14.         [color=green] ' Write out the textbox values to the file.[/color]
    15.         Print #1, "Record Created: " & txtDateTime.Text & _
    16.         "   By: " & txtUserName.Text & vbCrLf
    17.        
    18.         [color=green] 'Followed by the original file's text.[/color]
    19.         Print #1, strFileText
    20.    
    21.     Close #1
    22.    
    23. End Sub

    Please rate this post if it was useful for you!
    Please try to search before creating a new post,
    Please format code using [ code ][ /code ], and
    Post sample code, error details & problem details

  7. #7
    Evil Genius alex_read's Avatar
    Join Date
    May 2000
    Location
    Espoo, Finland
    Posts
    5,538
    Deju, just take out all of the lines in my sample code which have "strFileText" in them & the entry written to the file will replace the text which is already there.

    Please rate this post if it was useful for you!
    Please try to search before creating a new post,
    Please format code using [ code ][ /code ], and
    Post sample code, error details & problem details

  8. #8
    Lively Member
    Join Date
    May 1999
    Location
    belgium
    Posts
    74
    Is it also possible the check the filesize? For instance is a file is > 1MB then clean it.

  9. #9
    Evil Genius alex_read's Avatar
    Join Date
    May 2000
    Location
    Espoo, Finland
    Posts
    5,538
    Take a look at the GetFileSize API call either by searching the API forum or on www.allapi.net.

    Please rate this post if it was useful for you!
    Please try to search before creating a new post,
    Please format code using [ code ][ /code ], and
    Post sample code, error details & problem details

  10. #10
    Frenzied Member swatty's Avatar
    Join Date
    Aug 2002
    Location
    somewhere on earth
    Posts
    1,478

    Deju alive and kicking

    Originally posted by Deju
    Is it also possible the check the filesize? For instance is a file is > 1MB then clean it.

    And did you find it ??
    Code:
    If Question = Incomplete Then
       AnswerNextOne
    Else
       ReplyIfKnown
    End If
    cu Swatty

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