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

  • 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]

  • [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.


  • 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]

  • : 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."

  • : : 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.

Howdy, Stranger!

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

Categories