Results 1 to 4 of 4

Thread: A better way...

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jan 1999
    Location
    California
    Posts
    115

    Post

    Ok, I know there HAS to be a better way to do this.

    Code:
    If InStr(Form8.Text1.Text, "Error 301") > 0 Then
    If AddList = 1 Then
    AddList = 0
    List4.AddItem "[" & ErrorCurrentURL & "] at " & Time
    List1.AddItem StartError & ErrorCurrentURL ">" & ErrorCurrentURL & MiddleError & "Error: Moved Permanently</a> - " & Format(Now, "h:mm AM/PM") & " - " & Format(Date, "mm/d/yy") & EndError
    End If
    Timer1.Enabled = False
    End If
    
    If InStr(Form8.Text1.Text, "Error 404") > 0 Then
    If AddList = 1 Then
    AddList = 0
    List4.AddItem "[" & ErrorCurrentURL & "] at " & Time
    List1.AddItem StartError & ErrorCurrentURL ">" & ErrorCurrentURL & MiddleError & "Error: Page Not Found</a> - " & Format(Now, "h:mm AM/PM") & " - " & Format(Date, "mm/d/yy") & EndError
    End If
    Timer1.Enabled = False
    End If
    I would have to make 20 some odd of those if statements to check for different errors, is there a way to set the errors and variables and also the discription of the error to go with it. The "Error 404" error goes with the "Page Not Found" discription, etc.

    Thanks in advance,

    ------------------
    Ryan French
    Niresoft Incorporated
    http://www.niresoft.com
    [email protected]

  2. #2
    Addicted Member
    Join Date
    Oct 1999
    Location
    Oporto, Portugal
    Posts
    134

    Post

    Try this:

    - Create a text (error.txt) file with the errors you want to check in it.
    - On form_load input from the text file to an array of a custom type. Like:

    Private Type ListErrors
    ErrorCode As String
    ErrorMeaning As String
    End Type


    Dim ErrorCheck() as ListErrors

    - Create a function with a For Next statement until the UBound of the array you created.

    With a dozen of lines of code you do it and then with just a call to a func you have your result.

    If you have any problem creating this e-mail me.


    ------------------
    Jorge Ledo
    [email protected]
    Portugal

    [This message has been edited by JorgeLedo (edited 02-08-2000).]

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Jan 1999
    Location
    California
    Posts
    115

    Post

    The errors must be built in, that way the user can't mess it up in any way.

  4. #4
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Post

    You probably want to use a resource file to store the error messages. It will take me a little while but I will create a demo project for you and email it to you.

    ------------------
    Marty
    What did the fish say when it hit the concrete wall?
    > > > > > "Dam!"

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