executing different formulae based on null values

Discussion in 'AutoCAD' started by George, Aug 30, 2004.

  1. George

    George Guest

    Hi All,

    I have a dialog box that is used to collect four values and perform calcs
    based on the values. My objective is to calculate the value of the empty
    edit box, given the other parameters. For example, A+B+C=D but if the user
    lets B blank, B is calculated. I know how to rearrange the formulae but how
    do I test which formula to apply and then actually apply it?

    Thanks,
    GLC
     
    George, Aug 30, 2004
    #1
  2. If you are saying 1 of the boxes is to be empty and it can be any of them,
    make sure you have a button to do the calc. The first thing the button
    should do is check for only 1 empty value. A simple way would be to create
    a Collection object and have the Exit event [vba] for the textbox add its
    value to the collection. Then before doing the calc, check to make sure
    there are 3 items in the collection. From there, use an If..ElseIIf
    structure to determine which formula to use:

    If myCollection.Count = 3 Then
    If TextboxA.Text = vbnullstring Then
    A = B+C+D
    ElseIf TextboxB.Text vbnullstring Then
    B = A+C+D
    ElseIf TextboxC.Text = vbnullstring Then
    C = A+B+D
    Else
    'Must be D
    D = A+B+C
    End If
    End If
    'make sure to reset your collection for next pass
    Set myCollection = New Collection

    -- Mike
    ___________________________
    Mike Tuersley
    CADalyst's CAD Clinic
    Rand IMAGINiT Technologies
    ___________________________
    the trick is to realize that there is no spoon...
     
    Mike Tuersley, Aug 30, 2004
    #2
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.