+ Reply to Thread
Results 1 to 2 of 2

array problem

  1. #1
    Rbp9ad
    Guest

    array problem

    I am developing an application in excel. It uses a userform to display
    invoice records to the managers that can approve them. The userform has a
    split button if a particular invoice needs to be coded to more than one
    account. This button opens another userform where the manager can put
    amounts in the various account codes. It has a next, done and cancel button.

    I am having trouble with the logic of the next button. I want it to create a
    two dimensional array with a variable number of records. The dimensions
    would be the amount and the account. I want to create this array in order to
    reconcile the amounts of the splits with the total invoice amount before it
    is written to the workbook.

    dim myarr() as variant
    sub next button click

    redim myarr(1 to 2,0)
    myarr(1,0) = account.text
    myarr(2,0)=amount.text

    For the first record

    redim myarr(1 to 2, ubound(myarr) + 1)
    myarr(1,ubound(myarr)) = account.text
    myarr(2,ubound(myarr))=amount.text

    for subsequent records

    i am having trouble with differentiating between the first account and
    amount and subsequent ones. When the array is initially declared would it
    have a value of zero or empty? How can I write code to see if an array is
    empty?



  2. #2
    Tom Ogilvy
    Guest

    Re: array problem

    dim myarr() as variant
    sub next button click

    redim myarr(1 to 2,0 to 0)
    myarr(1,0) = account.text
    myarr(2,0)=amount.text

    For the first record

    redim myarr(1 to 2, ubound(myarr) + 1)
    myarr(1,ubound(myarr)) = account.text
    myarr(2,ubound(myarr))=amount.text

    >When the array is initially declared would it
    > have a value of zero or empty?


    on way to check is to error trap:
    Sub aaa()
    Dim myarray()
    Dim ub As Variant
    On Error Resume Next
    ub = UBound(myarray)
    On Error GoTo 0
    If IsEmpty(ub) Then
    MsgBox "Not initialized"
    End If
    End Sub

    --
    Regards,
    Tom Ogilvy




    "Rbp9ad" <rob.patterson@lightcore.net> wrote in message
    news:e0xMJhQ9FHA.3908@TK2MSFTNGP10.phx.gbl...
    > I am developing an application in excel. It uses a userform to display
    > invoice records to the managers that can approve them. The userform has a
    > split button if a particular invoice needs to be coded to more than one
    > account. This button opens another userform where the manager can put
    > amounts in the various account codes. It has a next, done and cancel

    button.
    >
    > I am having trouble with the logic of the next button. I want it to create

    a
    > two dimensional array with a variable number of records. The dimensions
    > would be the amount and the account. I want to create this array in order

    to
    > reconcile the amounts of the splits with the total invoice amount before

    it
    > is written to the workbook.
    >
    > dim myarr() as variant
    > sub next button click
    >
    > redim myarr(1 to 2,0)
    > myarr(1,0) = account.text
    > myarr(2,0)=amount.text
    >
    > For the first record
    >
    > redim myarr(1 to 2, ubound(myarr) + 1)
    > myarr(1,ubound(myarr)) = account.text
    > myarr(2,ubound(myarr))=amount.text
    >
    > for subsequent records
    >
    > i am having trouble with differentiating between the first account and
    > amount and subsequent ones. When the array is initially declared would it
    > have a value of zero or empty? How can I write code to see if an array is
    > empty?
    >
    >




+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1