Results 1 to 6 of 6

Thread: 'ReDim' cannot change the number of dimensions of an array.

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2003
    Posts
    7

    'ReDim' cannot change the number of dimensions of an array.

    THIS IS MY CODE AND IM HAVING UPDATE VB 6.0 VB .NET
    'ReDim' cannot change the number of dimensions of an array.
    HELP PLEASE WHAT'S MISSING
    THANKS ALL


    Private Sub cmdStart_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdStart.Click


    Dim aryCount() As Integer
    Dim HiCard As Integer
    Dim Decks As Integer

    Select Case MachineType
    Case 12, 15, 17 : HiCard = 6 : Decks = 0 : Devices = 2 : CardLength = 1 'craps
    Case Else : Err.Raise(vbObjectError + 1086, , "" & MachineType)
    End Select

    If Devices = 0 Then
    ReDim aryCount(HiCard + 4)
    Else
    ReDim aryCount(HiCard, Devices) <<<<<<<THIS IS THE ARRAY IM having the problem with>>>>>>>>>>
    End If


    THIS IS THE ERROR: I GET

    'ReDim' cannot change the number of dimensions of an array.

  2. #2
    Fanatic Member VBCrazyCoder's Avatar
    Join Date
    Apr 2003
    Posts
    681
    Maybe it is:
    ReDim aryCount(HiCard + 4)
    You might not be able to ReDim to a runtime value?? Not sure, but it might be easier to use an array list.

  3. #3
    Frenzied Member
    Join Date
    Oct 2002
    Location
    Gammapolis
    Posts
    1,474
    From MSDN
    The ReDim statement is used to change the size of one or more dimensions of an array that has already been formally declared. ReDim cannot change the rank (the number of dimensions) of the array.
    Last edited by Lunatic3; Apr 23rd, 2003 at 03:07 PM.
    'Heading for the automatic overload'
    Marillion, Brave, The Great Escape, 1994

    'How will WE stand the FIRE TOMORROW?'
    Eloy, Silent Cries and Mighty Echoes, The Vision - Burning, 1979

  4. #4

    Thread Starter
    New Member
    Join Date
    Apr 2003
    Posts
    7
    VBCrazyCoder

    this code is fine!!!

    ReDim aryCount(HiCard + 4)


    it this code im having problems with

    ReDim aryCount(HiCard, Devices)

    thanks

  5. #5
    Member
    Join Date
    Sep 2002
    Posts
    53
    You've have dimmed an array, then redimming it as a multidimentional array.

    Dim the array initially with (,)

  6. #6
    New Member
    Join Date
    Apr 2003
    Location
    Nottingham
    Posts
    14
    Also from MSDN:

    If your array has two or more dimensions, you can change the size of only the last dimension if you use Preserve.

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