Results 1 to 2 of 2

Thread: Logging

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Aug 2000
    Location
    Ireland
    Posts
    224

    Question

    Here's a part of my code. What I'm trying to do is put checkpoints at certain stages of my code that will Print a line of text to my log file stating that the code has at that particular point has executed correctly. Do I have to reopen the log file each time I want to do a check. I've only started VB this week and am still a bit lost. Any help would be greatly appreciated.

    Thanks a lot.





    Sub ComOK_Click ()
    On Error GoTo ChangePW_ComOK_Click_Err
    'Code by JK to investigate Password Errors
    'Creates a log file called DebugJK.log
    filenum = FreeFile
    Open "C:\temp\DebugJK.log" For Append As #filenum
    Print #filenum, "____Purpose of Logfile____: To determine any errors in the CHANGEPW.FRM "
    Print #filenum, "Last modified: "; Now
    'End JK
    If TextOldPassword.Text <> "" Then
    25 : UserSS.FindFirst ("[User Name] = '" + who.Name + "'")
    enc$ = encode(CStr(who.Name), CStr(TextOldPassword.Text))
    If (enc$ <> UserSS!Password) Or (who.Name <> UserSS![User Name]) Then Error 99
    'Added JK
    Print #filenum, "The oldPasswordCheck has been run successfully"
    Close #filenum
    ' End JK
    If Len(TextNewPassword.Text) < 6 Then
    Text = messageList(30) ' Password must have at least 6 characters
    MsgBox Text, MB_ICONEXCLAMATION, "Password Change"
    TextNewPassword.Text = ""
    TextConfirm.Text = ""
    TextNewPassword.SetFocus
    Exit Sub
    End If

  2. #2
    Frenzied Member Jop's Avatar
    Join Date
    Mar 2000
    Location
    Amsterdam, the Netherlands
    Posts
    1,986
    hmmm, thinks the're nothing wrong with your code.

    but in post you could use code and /code (but brackets around them [ and ]) and the post would be better to read, like
    Code:
    Sub ComOK_Click () 
    On Error GoTo ChangePW_ComOK_Click_Err 
    'Code by JK to investigate Password Errors 
    'Creates a log file called DebugJK.log 
    filenum = FreeFile 
    Open "C:\temp\DebugJK.log" For Append As #filenum 
    Print #filenum, "____Purpose of Logfile____: To determine any errors in the CHANGEPW.FRM " 
    Print #filenum, "Last modified: "; Now 
    'End JK 
    If TextOldPassword.Text <> "" Then 
    25 : UserSS.FindFirst ("[User Name] = '" + who.Name  + "'") 
    enc$ = encode(CStr(who.Name), CStr(TextOldPassword.Text)) 
    If (enc$ <> UserSS!Password) Or (who.Name <> UserSS![User Name]) Then Error 99 
    'Added JK 
    Print #filenum, "The oldPasswordCheck has been run successfully" 
    Close #filenum 
    ' End JK 
    If Len(TextNewPassword.Text) < 6 Then 
    Text = messageList(30) ' Password must have at least 6 characters 
    MsgBox Text, MB_ICONEXCLAMATION, "Password Change" 
    TextNewPassword.Text = "" 
    TextConfirm.Text = "" 
    TextNewPassword.SetFocus 
    Exit Sub 
    End If
    and in general it's a goob habit to put tabs in your code to make it clearer to read like:

    Code:
    If Condition Then
        DoThis
        DoThat
        Unload Me
    End If
    Hope this helped (a bit)
    Jop - validweb.nl

    Alcohol doesn't solve any problems, but then again, neither does milk.

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