Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Facebook Sign In with Google Sign In with OpenID

Categories

We have migrated to a new platform! Please note that you will need to reset your password to log in (your credentials are still in-tact though). Please contact lee@programmersheaven.com if you have questions.
Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Yet another problem...

[b][red]This message was edited by aaronjones3593 at 2007-2-27 3:17:27[/red][/b][hr]

Got another problem now.
I don't know what's wrong with me I used to be able to program fine lol.

[code]

...

Dim iContinue As Integer

Dim BallotAddCount As Integer
Dim NewBallotCount As Integer
BallotAddCount = 0

Do While iContinue = vbYes

NewBallotCount = NumberOfBallots + BallotAddCount + 1
[red]ReDim Preserve VoteArray(NewBallotCount, NumberOfCandidates)[/red]

...

BallotAddCount = BallotAddCount + 1
iContinue = MsgBox("You have added " & BallotAddCount & " ballots." & vbNewLine & _
"Would you like to add more?", vbYesNo + vbApplicationModal, _
"Add Another Ballot: Yes or No?")


Loop

...

[/code]

NumberOfBallots = 10
NumberOfCandidates = 4 [Got from inputbox]

Array was already VoteArray(NumberOfBallots, NumberOfCandidates)

[I'm coding a transferrable vote system]

ReDim Preserve blahblah don't wanna do it
[Subscript out of range]

btw I'm using Option Base 1

And the subscript IS IN RANGE
[I checked with the locals window]


-( Aaron )-
"Pain doesn't hurt, if it's all you've ever felt."






Comments

  • KhalilDutchKhalilDutch Posts: 74Member
    Aaron,

    This is from the MSDN Library and should explain your problem...

    [code]If you use the Preserve keyword, you can resize only the last array
    dimension and you can't change the number of dimensions at all.
    For example, if your array has only one dimension, you can resize that
    dimension because it is the last and only dimension. However, if your
    array has two or more dimensions, you can change the size of only the last
    dimension and still preserve the contents of the array. [/code]

    Cheers,
    [b]--Khalil[italic][red]Dutch[/red]--[/italic][/b]
    ___________________________
    [code]If ... Then
    ...
    Else
    ...
    Whatever....[/code]

  • aaronjones3593aaronjones3593 Posts: 122Member
    [b][red]This message was edited by aaronjones3593 at 2007-2-27 4:45:14[/red][/b][hr]

    So I have to swap Ballots for Candidates then?

    i.e. from VoteArray(NoOfBallots, NoOfCandidates)
    to VoteArray(NoOfCandidates, NoOfBallots)

    Because from this point in the code I only [red]eveer[/red] [green]ever[/green] need to change the number of Ballots.


  • KhalilDutchKhalilDutch Posts: 74Member
    If your NoOfBallots is the variable one, yes you do.

    Cheers!
    [b]--Khalil[italic][red]Dutch[/red]--[/italic][/b]
    ___________________________
    [code]If ... Then
    ...
    Else
    ...
    Whatever....[/code]

  • aaronjones3593aaronjones3593 Posts: 122Member
    : If your NoOfBallots is the variable one, yes you do.

    Damnit, that's a pain in the ass.

    Oh well. -sighs- thanks for your assistance, I'll get started on that now I guess... Only, 80 lines to go through swapping nested loops and variable names?

    lol. thankyou.


    -( Aaron )-
    "Pain doesn't hurt, if it's all you've ever felt."

  • BitByBit_ThorBitByBit_Thor Posts: 2,444Member
    : : If your NoOfBallots is the variable one, yes you do.
    :
    : Damnit, that's a pain in the ass.
    :
    : Oh well. -sighs- thanks for your assistance, I'll get started on that now I guess... Only, 80 lines to go through swapping nested loops and variable names?
    :
    : lol. thankyou.
    :
    :
    : -( Aaron )-
    : "Pain doesn't hurt, if it's all you've ever felt."
    :
    :

    Or write some code to manually preserve the items.

    Best Regards,
    Richard

    The way I see it... Well, it's all pretty blurry

Sign In or Register to comment.