Thread: UBound Problem

    #1
  1. Contributing User
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Dec 2004
    Location
    Meriden, Connecticut
    Posts
    1,797
    Rep Power
    154

    UBound Problem


    The last part of my bot, which is needed to connect it, contains the VB6 function UBound, I'm not sure what to use in Python that is like this function. I found the following info on hiddensoft.com.
    Code:
    Success: Returns the size of the array dimension. 
    Failure: Returns 1 and sets @error to 1 if dimension is invalid or if variable is not an array!
    My code that contains UBound is,
    Code:
        SplitStr strData, strStrings, vbCrLf
        For i = 1 To UBound(strStrings)
            Parse2 strStrings(i)
        Next i
    I already understand the SplitStr part and the Parse2 part. I just don't know what to make UBound into.
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Nov 2003
    Posts
    624
    Rep Power
    34
    Returns the size of the array dimension.
    Directly it would be "len(something)", but since all it's doing is counting through items in the array, you can do away with the counting bit in Python and directly get each item in the array, so:

    Code:
    For i = 1 To UBound(strStrings)
        Parse2 strStrings(i)
    Next i
    becomes

    Code:
    for item in strStrings:
        Parse2(item)
  4. #3
  5. Contributing User
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Dec 2004
    Location
    Meriden, Connecticut
    Posts
    1,797
    Rep Power
    154
    Thanks so much sfb.

IMN logo majestic logo threadwatch logo seochat tools logo