Results 1 to 6 of 6

Thread: dynamic array

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2002
    Location
    UK
    Posts
    506

    Unhappy dynamic array

    VB Code:
    1. Dim strDescription As String, intTemp As Integer, intContains As Integer
    2. For Each Item In strFullError
    3.     intContains = intContains + 1
    4. Next
    5. intContains = intContains - 1
    6. MsgBox intContains
    7. For intTemp = 0 To intContains Step 1
    8.     intTemp = intTemp + 1
    9.     MsgBox intTemp
    10.     MsgBox strFullError(intTemp)
    11.     strDescription = strDescription & " " & strFullError(intTemp)
    12. Next
    im tryin to get all of the indexes from an array except for the first one (0) but when the second for loop runs, it increments in 2s? and goes from 1 to 3 so im gettin a subscript out of range errormibob, anyone know why?
    cheers

    ps, its in a function where strfullerror is declared as an arrayed string like strFullError() as String, im new to arrays please bare with mee :P

  2. #2
    Need-a-life Member Mc Brain's Avatar
    Join Date
    Apr 2000
    Location
    Buenos Aires, Argentina
    Posts
    6,808
    Try this:

    VB Code:
    1. Dim strDescription As String, intTemp As Integer, intContains As Integer
    2. For Each Item In strFullError
    3.     intContains = intContains + 1
    4. Next
    5. intContains = intContains - 1
    6. MsgBox intContains
    7. For intTemp = 1 To intContains
    8.     MsgBox intTemp
    9.     MsgBox strFullError(intTemp)
    10.     strDescription = strDescription & " " & strFullError(intTemp)
    11. Next
    Emiliano F. Martín


    If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
    Encourage the person who helped you to keep doing it, and give him the points he deserves.


    MP3 Organizer: Freeware to logically organize all your MP3s.

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2002
    Location
    UK
    Posts
    506
    oo, taaaaaa! i cant even see wat u changed let me take a closer look cheers again

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2002
    Location
    UK
    Posts
    506
    o i c!! the for increments it itself so mine was doin it twice.. haha im stupid :P

  5. #5
    Need-a-life Member Mc Brain's Avatar
    Join Date
    Apr 2000
    Location
    Buenos Aires, Argentina
    Posts
    6,808
    Originally posted by adzzzz
    oo, taaaaaa! i cant even see wat u changed let me take a closer look cheers again
    I changed the limits of the For to start at 1, and remove the increment of the variable line.
    Emiliano F. Martín


    If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
    Encourage the person who helped you to keep doing it, and give him the points he deserves.


    MP3 Organizer: Freeware to logically organize all your MP3s.

  6. #6
    Fanatic Member daydee's Avatar
    Join Date
    Jun 2001
    Location
    Canada
    Posts
    560
    VB Code:
    1. Public Function CountArIndx(myArray() As String) As Integer
    2.     For CountArIndx = LBound(myArray()) To UBound(myArray())
    3.     'MsgBox CountArIndx
    4.     Next
    5. End Function
    Is this what you need?
    Stick this in a module and just call it up. This will return the number of indexes contained in your array.
    Give your music collection a whole new life with PartyTime Jukebox

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