Results 1 to 4 of 4

Thread: parse(0) = <Subscript out of range> ??[solved]

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Apr 2004
    Location
    sweden
    Posts
    176

    parse(0) = <Subscript out of range> ??[solved]

    Hi.
    What can i do to prevent this from happen?
    Code:
    parse = Split(lstNowWarn.List(l), ":")
    numbers = parse(0)
    names = parse(1)
    errors:
    parse(0) = <Subscript out of range>
    parse(1) = <Subscript out of range>
    Big Thanks,
    naitsabes
    Last edited by naitsabes85; Jan 6th, 2005 at 04:34 PM.

  2. #2
    Hyperactive Member
    Join Date
    Jun 2004
    Posts
    468

    Re: parse(0) = <Subscript out of range> ??

    Check how many splits were created:
    VB Code:
    1. Dim Splits As Long
    2. Splits = UBound(Parse) - LBound(Parse) + 1
    3. If Splits > 0 Then Numbers = Parse(0)
    4. If Splits > 1 Then Names = Parse(1)

  3. #3
    PowerPoster BruceG's Avatar
    Join Date
    May 2000
    Location
    New Jersey (USA)
    Posts
    2,657

    Re: parse(0) = <Subscript out of range> ??

    bpd is correct. FYI, if the string you are trying to split is an empty string (""), the Split function will set the UBound of the resulting array to -1.
    I would do it similar to this:
    VB Code:
    1. If lstNowWarn.List(l) <> "" then
    2.     parse = Split(lstNowWarn.List(l), ":")
    3.     numbers = parse(0)   ' you get at least this
    4.     If UBound(parse) > 0 Then
    5.         names = parse(1)
    6.     End If
    7. End If
    "It's cold gin time again ..."

    Check out my website here.

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Apr 2004
    Location
    sweden
    Posts
    176

    Re: parse(0) = <Subscript out of range> ??

    thanks guys, i try this.
    naitsabes

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