Results 1 to 4 of 4

Thread: Displaying a failed line to the user

  1. #1

    Thread Starter
    Member
    Join Date
    Apr 2003
    Posts
    49

    Displaying a failed line to the user

    Hi,
    I read data from a file and copy each element in each row to an array. I then assign each element in the array to the correct datatype before passing to a stored proc to load into a table. E.g

    strArray() = Split(strLine, ",")

    dteInvoice = strArray(0)
    lngNumber = strArray(1)

    If the data is invalid and hence can't be stored in that particular datatype, it jumps to my error handler and captures the error code.

    I would then like to display a message that strArray(x) is invalid.

    Without having a counter that stores the value of x is there anyway of displaying the value of the current variable being processed?

  2. #2
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974
    not really... there are other methods, but the way you suggested is the easiest and the quickest (as other methods would mean repeating the same code with similar modifications anyway)

  3. #3
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974
    by the way, you could do some simple checking first, eg:
    VB Code:
    1. If IsDate(strArray(0)) Then
    2.   dteInvoice = strArray(0)
    3. Else
    4.   'error in date - show appropriate message & exit
    5. End If
    6.  
    7. If IsNumeric(strArray(1)) Then
    8.   lngNumber = strArray(1)
    9. Else
    10.   'error in number - show appropriate message & exit
    11. End If
    but that wont completely stop errors occuring

  4. #4

    Thread Starter
    Member
    Join Date
    Apr 2003
    Posts
    49
    Thanks that's useful but it wouldn't trap other errors like overflow,etc.

    I'll stick with using an index counter and just check it in the error handler. It was speed I was concerned with though

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